Spiral gives your agent every tool with one account. Browse the tools →

AlexandriaPublic RecordsAvailable now

Socrata open-data portals · Query dataset

socrata-com/open-data/query_dataset

Search 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

FieldKindDefaultDescription
portal requiredtext—

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 requiredtext—

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.

qtext—

Full-text search across the dataset's text columns.

grouptext—

SoQL $group, e.g. permit_type (with an aggregate in select).

limitnumber
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.

ordertext—

SoQL $order, e.g. issue_date DESC. Defaults to the row id :id for stable paging (none for aggregates).

wheretext—

SoQL $where without the keyword. String literals in single quotes ('O''Hare' escapes a quote). E.g. issue_date >= '2024-01-01' AND permit_type = 'PERMIT - NEW CONSTRUCTION', within_circle(location, 41.88, -87.63, 500).

offsetnumber
0 to 100000000
0

Row offset (next_offset of the previous page).

selecttext—

SoQL $select without the keyword: columns, aliases, aggregates. E.g. permit_, permit_type, issue_date or permit_type, count(*) AS n.

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.