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.

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

For example:

https://data.gov.sg/api/action/datastore_search

If you're looking to query the following dataset: https://data.gov.sg/datasets/d_8b84c4ee58e3cfc0ece0d773c8ca6abc/view 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_8b84c4ee58e3cfc0ece0d773c8ca6abc

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
200

Fetched data

application/json
get
/api/action/datastore_search

Last updated

Was this helpful?