ckan_query
Query government spending and procurement data from CKAN datastores (data.ca.gov, data.virginia.gov, data.boston.gov) using a resource ID, with optional filters, full-text search, and pagination.
Instructions
Query rows from an allowlisted CKAN datastore resource (keyless; the FIRST source on the R2 DataSource port — state/city spend/checkbook/procurement/vendor tables on the identical CKAN Action API). Input host (curated allowlist enum — the SSRF host guard: data.ca.gov, data.virginia.gov, data.boston.gov), resourceId (36-char lowercase UUID, from ckan_discover_datasets), optional q (full-text), filters (constrained object {field:value} we JSON.stringify), sort, limit (≤1000, def 100), offset. HONESTY: CKAN's envelope carries a real result.total — the DEFAULT is an EXACT total (exact totalAvailable + hasMore); the rare estimated total (total_was_estimated:true) is disclosed via totalIsEstimated + a note and does NOT drive pagination (it can be above OR below the truth). Genuine-empty ⇒ complete:true/total:0; an outage/404/409 or success:false THROWS (never a fake empty). Values are typed per result.fields[].type.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| q | No | Optional full-text search across the record (CKAN `q`). | |
| host | Yes | Which allowlisted CKAN portal to query (curated .gov hosts — the SSRF host allowlist, no free host): data.ca.gov (CA), data.virginia.gov (VA — eVA), data.boston.gov (City of Boston Checkbook). | |
| sort | No | Optional sort, e.g. '_id asc' or 'amount desc'. A bad field ⇒ 409 ⇒ invalid_input. | |
| limit | No | Rows per page, 1..1000, default 100. | |
| offset | No | 0-based row offset for pagination, default 0. | |
| filters | No | Optional structured field filters, e.g. {"Fiscal Year":"2013-2014"}. A constrained object (string/number/array values only) that we JSON.stringify; a bad field ⇒ upstream HTTP 409 ⇒ invalid_input (surfaced, never silent). | |
| resourceId | Yes | The datastore resource_id, a 36-char lowercase UUID e.g. 'bb82edc5-9c78-44e2-8947-68ece26197c5' (from ckan_discover_datasets, a datastoreActive:true resource). |