Download dataset

Guide to downloading datasets

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.

Initiates download for a dataset

get
Path parameters
datasetIdstringRequired

ID of the dataset

Header parameters
x-api-keystringOptional

API key for higher rate limits (optional)

Body
columnNamesstring[]Optional

List of selected columns in filtered dataset.

Example: ["name","title","address","email_address"]
filtersarrayOptional

Filters defines how users want to filter their dataset. Filters is an array of objects which have columnName,type and value attributes. columnName refers to the column where the filter is to be applied. The values for type can be EQ, LIKE, or ILIKE. EQ is direct comparison for filter and is case sensitive. LIKE is similar to EQ but includes partial matching. Any words containing the string in the value attribute will be matched. ILIKE is the case-insensitive version of LIKE.

Example: {"fitlers":[{"columnName":"epi_week","type":"EQ","value":2},{"columnName":"status","type":"ILIKE","value":"covid"},{"columnName":"epi_year","type":"LIKE","value":23}]}
Responses
201
Successful response
application/json
get
GET /v1/public/api/datasets/{datasetId}/initiate-download HTTP/1.1
Host: api-open.data.gov.sg
Content-Type: application/json
Accept: */*
Content-Length: 236

{
  "columnNames": [
    "name",
    "title",
    "address",
    "email_address"
  ],
  "filters": {
    "fitlers": [
      {
        "columnName": "epi_week",
        "type": "EQ",
        "value": 2
      },
      {
        "columnName": "status",
        "type": "ILIKE",
        "value": "covid"
      },
      {
        "columnName": "epi_year",
        "type": "LIKE",
        "value": 23
      }
    ]
  }
}
{
  "code": 1,
  "data": {
    "message": "text"
  },
  "errorMsg": "text"
}

After initiating the download of a dataset, this endpoint below returns a link to access the dataset

Poll download for a dataset after download has been initiated

get
Path parameters
datasetIdstringRequired

ID of the dataset

Body
columnNamesstring[]Optional

List of selected columns in filtered dataset.

Example: ["name","title","address","email_address"]
filtersarrayOptional

Filters defines how users want to filter their dataset. Filters is an array of objects which have columnName,type and value attributes. columnName refers to the column where the filter is to be applied. The values for type can be EQ, LIKE, or ILIKE. EQ is direct comparison for filter and is case sensitive. LIKE is similar to EQ but includes partial matching. Any words containing the string in the value attribute will be matched. ILIKE is the case-insensitive version of LIKE.

Example: {"fitlers":[{"columnName":"epi_week","type":"EQ","value":2},{"columnName":"status","type":"ILIKE","value":"covid"},{"columnName":"epi_year","type":"LIKE","value":23}]}
Responses
201
Successful response
application/json
get
GET /v1/public/api/datasets/{datasetId}/poll-download HTTP/1.1
Host: api-open.data.gov.sg
Content-Type: application/json
Accept: */*
Content-Length: 236

{
  "columnNames": [
    "name",
    "title",
    "address",
    "email_address"
  ],
  "filters": {
    "fitlers": [
      {
        "columnName": "epi_week",
        "type": "EQ",
        "value": 2
      },
      {
        "columnName": "status",
        "type": "ILIKE",
        "value": "covid"
      },
      {
        "columnName": "epi_year",
        "type": "LIKE",
        "value": 23
      }
    ]
  }
}
{
  "code": 1,
  "data": {
    "status": "text",
    "url": "text"
  },
  "errorMsg": "text"
}

Last updated

Was this helpful?