Dataset APIs
Last updated
Was this helpful?
Last updated
Was this helpful?
To find the datasetId, refer to the URL of dataset.
For this dataset:
https://beta.data.gov.sg/collections/522/datasets/d_11e68bba3b3c76733475a72d09759eeb/view
or
https://beta.data.gov.sg/datasets/d_11e68bba3b3c76733475a72d09759eeb/view
The datasetId is:
d_11e68bba3b3c76733475a72d09759eeb
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://beta.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
This API returns a list of all the datasets available on data.gov.sg
This API returns the metadata of a single dataset
As Data.gov is a public shared service, we will apply quotas to ensure that they are fairly used by all users. If you exceed the quota of 5 requests per minute, you’ll likely receive a 429 Error
This API initiates the download of a single dataset, with optional filtering by columns and rows. For datasets that do not have the CSV extension (ie GeoJSON, KML, PDF etc.), you may skip this endpoint and proceed to the Poll Download API below.
After initiating the download of a dataset, this endpoint below returns a link to access the dataset.
/api/action/datastore_search
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)
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"
/v1/public/api/datasets/{datasetId}/initiate-download
ID of the dataset
List of selected columns in filtered dataset.
["name","title","address","email_address"]
Filters defines how users want to filter their dataset.<br/> Filters is an array of objects which have columnName
,type
and value
attributes.<br/> columnName
refers to the column where the filter is to be applied.<br/> The values for type
can be EQ
, LIKE
, or ILIKE
.<br/> <li>EQ is direct comparison for filter and is case sensitive.</li> <li>LIKE is similar to EQ but includes partial matching. Any words containing the string in the value
attribute will be matched.</li> <li>ILIKE is the case-insensitive version of LIKE.</li> <br/>
{"fitlers":[{"columnName":"epi_week","type":"EQ","value":2},{"columnName":"status","type":"ILIKE","value":"covid"},{"columnName":"epi_year","type":"LIKE","value":23}]}
/v1/public/api/datasets/{datasetId}/poll-download
ID of the dataset
List of selected columns in filtered dataset.
["name","title","address","email_address"]
Filters defines how users want to filter their dataset.<br/> Filters is an array of objects which have columnName
,type
and value
attributes.<br/> columnName
refers to the column where the filter is to be applied.<br/> The values for type
can be EQ
, LIKE
, or ILIKE
.<br/> <li>EQ is direct comparison for filter and is case sensitive.</li> <li>LIKE is similar to EQ but includes partial matching. Any words containing the string in the value
attribute will be matched.</li> <li>ILIKE is the case-insensitive version of LIKE.</li> <br/>
{"fitlers":[{"columnName":"epi_week","type":"EQ","value":2},{"columnName":"status","type":"ILIKE","value":"covid"},{"columnName":"epi_year","type":"LIKE","value":23}]}