Get Statistics for Places.

Returns a time series of statistical values for queried places based on the StatisticalVariable. See the full list of StatisticalVariables.

URL: /bulk/stats

Method: POST

Auth required: Optional

Required Arguments:

You can find a list of StatisticalVariables with human-readable names here.

Optional Arguments:

  • key: Your API key.

POST Request

Example

curl -X POST 'https://api.datacommons.org/bulk/stats' \
-d '{ "place": ["geoId/05", "geoId/06085"], "stats_var": "Count_Person_Male"}'

Success Response

Code: 200 OK

Response content example

{
    "payload": "<payload string>",
}

The “payload string” is a JSON string that contains the time series of the queried places.

{
  "geoId/05": {
    "data": {
      "2011": 1421287,
      "2012": 1431252,
      "2013": 1439862,
      "2014": 1447235,
      "2015": 1451913,
      "2016": 1456694,
      "2017": 1461651,
      "2018": 1468412
    }
  },
  "geoId/06085": {
    "data": {
      "2011": 885307,
      "2012": 898013,
      "2013": 910196,
      "2014": 924848,
      "2015": 939004,
      "2016": 949223,
      "2017": 963317,
      "2018": 970469
    }
  }
}

The json contains an object keyed by place DCID. The value contains the place name and a “data” object keyed by the observation date and value being the actual statistics.

NOTE: Please run JSON.parse() on the payload field to retrieve the data. For example, in JavaScript: var data = JSON.parse(response['payload']).

Error Response

Code: 500 Internal Server Error

Request example: (statistcal variable not specified)

curl -X POST 'https://api.datacommons.org/bulk/stats' \
-d '{ "place": ["geoId/05", "geoId/06"]}'

Response content example

{
  "code": 2,
  "message": "missing required arguments"
}