Search and filter within dataset
Datastore search
This API allows you to search for data within a dataset or scan through the rows of the dataset in a paginated manner.
Search Rows in Dataset
ID or alias of the resource to be searched against. This corresponds to the dataset_id (resource_id is a legacy reference)
Maximum number of rows to return (optional, default: 100)
100
Offset this number of rows (optional)
Fields to return (optional, default: all fields in original order)
Dictionary of matching conditions, e.g {"key1": "a", "key2": "b"}
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.
Comma-separated field names with ordering, eg.: "fieldname1, fieldname2 desc"
API key for higher rate limits (optional)
{"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 HTTP/1.1
Host: data.gov.sg
Accept: */*
{
"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"
}
}
}
Last updated
Was this helpful?