WE Data Tools

Census API

Census API Reference


Search

You may search the API for a specific topic by it’s given ID (ex. 8 – “Total – Age groups of the population”). You must specify a region ID (ex. S05075590009.00) and the census year (ex. 2021). You will receive a JSON object which depending if you set the aggregate flag will return separate data objects for each separate topic for each region OR you will receive a separate data object for each topic with the region’s combined. See the different responses on the right side.

Parameters:

  • region_id: The ID for the region(s) that you are searching. (comma-separated list of strings)
  • topic_id: The ID for the topic(s) that you are searching. (comma-separated list of strings)
  • census_year: The year of the census data that you are searching. (string)
  • aggregate: Flag whether to aggregate region data together or keep it separate. (true | false)
  • fields: Include specific fields in the returned data structure. (comma-separated list of strings)

Unsuccessful Response JSON

  • status: “error”
  • message: The issue that caused the error
  • 0: (Optional) You may also receive an optional array of debugging variables

Successful Response JSON

  • status: “success”
  • data: array
    • The data array will have two different configurations depending on if you set aggregate to true or false. See the examples to the right.

Download the Postman Collection

To play with the API yourself you can download this collection and open it within postman.

Example Success Response (No aggregations)

{
    "status": "success",
    "data": [
        {
            "row_id": 7892,
            "region_id": "S05075590009.00",
            "census_year": 2021,
            "topic_id": 2630,
            "total": 130,
            "total_male": 65,
            "total_female": 65
        }
    ]
}

Example Success Response (With aggregations)

{
    "status": "success",
    "data": {
        "region_ids": [
            "S05075590032.00",
            "S05075590101.03",
            "S05075590009.00"
        ],
        "aggregates": [
            {
                "census_year": 2021,
                "topic_id": 2,
                "total": "13587",
                "total_male": "0",
                "total_female": "0"
            },
            {
                "census_year": 2021,
                "topic_id": 3,
                "total": "29",
                "total_male": "0",
                "total_female": "0"
            },
            {
                "census_year": 2021,
                "topic_id": 4,
                "total": "7431",
                "total_male": "0",
                "total_female": "0"
            }
        ]
    }
}

Example Error Response

{
    "status": "error",
    "message": "Missing Census Year or Region ID or Topic ID.",
    "0": {
        "census_year": "2021",
        "region_id": [
            "S05075590009.00"
        ],
        "topic_id": false
    }
}