Search and filter within dataset

This API allows you to search for data within a dataset or scan through the rows of the dataset in a paginated manner.

circle-info

Note that the following API uses the domain: https://data.gov.sg

For example:

https://data.gov.sg/api/action/datastore_searcharrow-up-right

If you're looking to query the following dataset: https://data.gov.sg/datasets/d_8b84c4ee58e3cfc0ece0d773c8ca6abc/viewarrow-up-right Please refer to the URL from the dataset page, taking the dataset_id (starting with d_...), and passing that into your datastore search API query as shown below: https://data.gov.sg/api/action/datastore_search?resource_id=d_8b84c4ee58e3cfc0ece0d773c8ca6abcarrow-up-right

For staging, note that the dataset_id on production and staging might differ:

Search Rows in Dataset

get
Query parameters
resource_idstringRequired

ID or alias of the resource to be searched against. This corresponds to the dataset_id (resource_id is a legacy reference)

limitintegerOptional

Maximum number of rows to return (optional, default: 100)

Default: 100
offsetintegerOptional

Offset this number of rows (optional)

fieldsstringOptional

Fields to return (optional, default: all fields in original order)

filtersstringOptional

Dictionary of matching conditions, e.g {"key1": "a", "key2": "b"}

qstringOptional

Full text query. If it’s a string, it’ll search on all fields on each row. If it’s a dictionary as {“key1”: “a”, “key2”: “b”}, it’ll search on each specific field. This is recommended rather than searching the full table as the latter will slow down queries significantly.

sortstringOptional

Comma-separated field names with ordering, eg.: "fieldname1, fieldname2 desc"

Responses
chevron-right
200

Fetched data

application/json
and
anyOptionalExample: {"help":"https://data.gov.sg/api/3/action/help_show?name=datastore_search","success":true,"result":{"resource_id":"f9dbfc75-a2dc-42af-9f50-425e4107ae84","fields":[{"type":"numeric","id":"year"},{"type":"text","id":"level_1"},{"type":"numeric","id":"value"}],"records":[{"year":1960,"level_1":"Total Residents","value":1646400},{"year":1960,"level_1":"Total Male Residents","value":859600},{"year":1960,"level_1":"Total Female Residents","value":786800},{"year":1961,"level_1":"Total Residents","value":1646400},{"year":1961,"level_1":"Total Male Residents","value":859600}],"limit":5,"total":870,"_links":{"start":"/api/action/datastore_search?limit=5&resource_id=f9dbfc75-a2dc-42af-9f50-425e4107ae84","next":"/api/action/datastore_search?offset=5&limit=5&resource_id=f9dbfc75-a2dc-42af-9f50-425e4107ae84"}}}
get
/api/action/datastore_search

Last updated

Was this helpful?