Socrata open-data portals · Query dataset
socrata-com/open-data/query_datasetSearch public records with Socrata open-data portals · Query dataset from Alexandria through one Spiral API key. Any question that needs actual records or aggregates from an open-data dataset (permit lookups by address or number, inspection results, 311 requests by type, counts by category). Get the portal and 4x4 from search_datasets and field names from describe_dataset first. It runs in the background and returns structured JSON. Pay as you go, with no subscription.
Pricing
$0.00873 per call.
Limits
- Runs
- In the background
- Returns
- json
- Longest queue wait
- 1 hour
- Run deadline
- 5 minutes
- Longest run, end to end
- 225 minutes
- Largest inline input
- 1 MB
- Largest input file
- 2 GB
- Largest output
- 5 GB
Input
| Field | Kind | Default | Description |
|---|---|---|---|
portal required | text | — | The portal: its hostname (data.cityofchicago.org, data.ny.gov, www.dallasopendata.com) or any URL on it. Must be a Socrata domain served by the Socrata Discovery API (US or EU region); anything else fails with invalid_input not_socrata_portal before the host is contacted. |
dataset_id required | text | — | The dataset's Socrata 4x4 id (for example ydr8-5enu, from search_datasets) or a dataset URL on the same portal: /d/<id>, /<Category>/<Name>/<id>, /resource/<id>.json. |
q | text | — | Full-text search across the dataset's text columns. |
group | text | — | SoQL $group, e.g. |
limit | number 1 to 1000 | 100 | Rows per page (1-1000). A page is also cut at about 1 MB of row data; continue from next_offset. |
order | text | — | SoQL $order, e.g. |
where | text | — | SoQL $where without the keyword. String literals in single quotes ('O''Hare' escapes a quote). E.g. |
offset | number 0 to 100000000 | 0 | Row offset (next_offset of the previous page). |
select | text | — | SoQL $select without the keyword: columns, aliases, aggregates. E.g. |
Same request in code
curl https://api.spiral.ai/v1/runs \
-H "Authorization: Bearer $SPIRAL_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"provider": "alexandria",
"model": "socrata-com/open-data/query_dataset",
"input": {
"portal": "<portal>",
"dataset_id": "<dataset_id>"
}
}'Frequently asked questions
How much does Socrata open-data portals · Query dataset cost?
$0.00873 per call. You pay as you go from one Spiral balance, with no subscription, and a failed run is not charged.
How do I use Socrata open-data portals · Query dataset through an API?
Send `POST /v1/runs` with `"provider": "alexandria"`, `"model": "socrata-com/open-data/query_dataset"` and the input fields on this page, using one Spiral API key. It runs in the background: poll the run, or name a webhook to be told when it finishes.
Do I need an account with Alexandria to use Socrata open-data portals · Query dataset?
No. Spiral runs it on its own Alexandria account and charges your Spiral balance.
Can my AI agent use Socrata open-data portals · Query dataset?
Yes. Agents find and run it through Spiral's MCP server, CLI or agent skill, with the same API key.