socrata-cli
An unofficial command-line interface for the Socrata Open Data API (SODA).
Installation
Install the latest published release from PyPI:
uv tool install socrata-cli
or:
pip install socrata-cli
Requires Python 3.9+.
To install directly from GitHub before a PyPI release is available, or to test a development build that has not been published to PyPI:
uv tool install git+https://github.com/yonran/socrata-cli.git
Pin a tag for reproducible installs:
uv tool install git+https://github.com/yonran/socrata-cli.git@v0.1.0
Use PyPI for normal installation once a version has been released. Use GitHub URLs for unreleased changes, private testing, or exact commit installs.
Quickstart
# Query a dataset (by 4x4 ID or full URL)
socrata dataset query pitq-e56w --where "transaction_date > '2024-01-01'" --limit 50
# Download an entire dataset
socrata dataset download https://data.sfgov.org/resource/pitq-e56w --format csv
# Show dataset metadata
socrata dataset metadata pitq-e56w
# List columns
socrata dataset columns pitq-e56w
Configuration
Credentials
Create an API Key at https://<your-domain>/profile/edit/developer_settings, then add a credential set:
socrata config creds add mysf
# prompts for domain, Key ID, and Key Secret
Enable a credential set for its domain (only one active per domain at a time):
socrata config creds use mysf
Use --creds public to force unauthenticated access for a single invocation.
Default domain
Set a default domain so you can use bare 4x4 dataset IDs without a full URL:
socrata config domain set data.sfgov.org
When a full URL is provided, its domain is used directly and the matching enabled credential set is selected automatically.
Commands
socrata dataset query DATASET_REF
Query a dataset with optional SoQL filters.
| Option | Description |
|---|---|
--select |
Columns to return ($select) |
--where |
Row filter ($where) |
--order |
Sort order ($order) |
--group |
Group by ($group) |
--q |
Full-text search |
--limit |
Max rows (default: 1000) |
--offset |
Pagination offset |
--all |
Fetch all rows (streams, ignores --limit) |
-f / --format |
table (default), json, csv |
-o / --output |
Write to file instead of stdout |
socrata dataset download DATASET_REF
Stream all rows to a file.
| Option | Description |
|---|---|
-f / --format |
csv (default) or json |
-o / --output |
Output file (default: <id>.<fmt>) |
socrata dataset metadata DATASET_REF
Show dataset name, description, column types, and update timestamps.
socrata dataset columns DATASET_REF
List column names, types, and descriptions.
socrata config creds
| Subcommand | Description |
|---|---|
add NAME |
Add or update a credential set |
list |
List all credential sets |
use NAME |
Enable a credential set for its domain |
remove NAME |
Delete a credential set and its stored keys |
socrata config domain
| Subcommand | Description |
|---|---|
set DOMAIN |
Set the default domain for bare dataset IDs |
remove |
Clear the default domain |
Global Options
| Option | Description |
|---|---|
-c / --creds |
Credential set to use for this invocation |
--domain |
Override domain for this invocation |
--timeout |
Request timeout in seconds (default: 10) |
Releasing
This project publishes socrata-cli to PyPI from GitHub Actions using PyPI
trusted publishing. No PyPI API token is stored in GitHub.
GitHub installs and PyPI releases serve different purposes:
| Source | Use for |
|---|---|
PyPI (uv tool install socrata-cli) |
Normal public installs, dependency constraints, package mirrors, and stable releases |
GitHub (uv tool install git+https://...) |
Unreleased changes, private testing, and pinning an exact tag or commit before publishing |
One-time PyPI setup:
- Create or claim the
socrata-cliproject on PyPI. - Add a trusted publisher for the GitHub repository.
- Use workflow filename
.github/workflows/publish.yml. - Use environment name
pypi.
To publish a release:
uv build --clear
git tag v0.1.0
git push origin v0.1.0
The publish workflow builds the source distribution and wheel, then uploads them to PyPI. PyPI attestations are enabled in the publish step and are tied to GitHub's OIDC identity for the workflow run.
License
MIT
Metadata
Release files for socrata-cli 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| socrata_cli-0.1.0.tar.gz | 9.9 kB | With provenance | Details for socrata_cli-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| socrata_cli-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for socrata_cli-0.1.0-py3-none-any.whl |
Total release size: 23.6 kB
Release files / socrata_cli-0.1.0.tar.gz
| Download URL | socrata_cli-0.1.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d49fd495ae586150337018aca448cbaaf0b0e04ba8bdfd9d877062810051f2b
|
|
BLAKE2b-256 checksum How to use checksums |
2ddded02ed48e3a928de7cc86a1e65d29bde3b201bced8b2ed1c6f07ff0db0c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 10, 2026.
Transparency logRelease files / socrata_cli-0.1.0-py3-none-any.whl
| Download URL | socrata_cli-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60b79d12c2c0d5e161f7cf77689030f5e6e9520f82006905ac76ddbc577a5f5e
|
|
BLAKE2b-256 checksum How to use checksums |
00ac12cdecb57ea7c7cc0090903302ec38b6740b4398462cfa0cad3fabf7fafe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 10, 2026.
Transparency logSecurity for socrata-cli 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for socrata_cli-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 10, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.