CLI for the Socrata Open Data API
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file socrata_cli-0.1.0.tar.gz.
File metadata
- Download URL: socrata_cli-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d49fd495ae586150337018aca448cbaaf0b0e04ba8bdfd9d877062810051f2b
|
|
| MD5 |
081dbd6968181f79d4753b193f48128c
|
|
| BLAKE2b-256 |
2ddded02ed48e3a928de7cc86a1e65d29bde3b201bced8b2ed1c6f07ff0db0c0
|
Provenance
The following attestation bundles were made for socrata_cli-0.1.0.tar.gz:
Publisher:
publish.yml on yonran/socrata-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
socrata_cli-0.1.0.tar.gz -
Subject digest:
2d49fd495ae586150337018aca448cbaaf0b0e04ba8bdfd9d877062810051f2b - Sigstore transparency entry: 1492045962
- Sigstore integration time:
-
Permalink:
yonran/socrata-cli@ee8f9673a60f62248838fb3f01f533d94f5a597b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/yonran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ee8f9673a60f62248838fb3f01f533d94f5a597b -
Trigger Event:
push
-
Statement type:
File details
Details for the file socrata_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: socrata_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b79d12c2c0d5e161f7cf77689030f5e6e9520f82006905ac76ddbc577a5f5e
|
|
| MD5 |
6ac63d3770af8da5a2bf4e96d05c8ceb
|
|
| BLAKE2b-256 |
00ac12cdecb57ea7c7cc0090903302ec38b6740b4398462cfa0cad3fabf7fafe
|
Provenance
The following attestation bundles were made for socrata_cli-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on yonran/socrata-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
socrata_cli-0.1.0-py3-none-any.whl -
Subject digest:
60b79d12c2c0d5e161f7cf77689030f5e6e9520f82006905ac76ddbc577a5f5e - Sigstore transparency entry: 1492046068
- Sigstore integration time:
-
Permalink:
yonran/socrata-cli@ee8f9673a60f62248838fb3f01f533d94f5a597b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/yonran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ee8f9673a60f62248838fb3f01f533d94f5a597b -
Trigger Event:
push
-
Statement type: