Skill Tracer
Skills › Scientific Agent Skills › database-lookup › datacommons.md

datacommons.md

206 lines · skills/database-lookup/references/datacommons.md at 5f2bc03

Open on GitHub
1# Google Data Commons API
2

Google Data Commons API

Raw lines 1 to 2
3## Base URL
4
5```
6https://api.datacommons.org
7```
8

Base URL

https://api.datacommons.org
Raw lines 3 to 8
9## Authentication
11**API key required.** Obtain through https://apikeys.datacommons.org/.
13Pass as query parameter: `&key=YOUR_KEY`
15Or as header: `X-API-Key: YOUR_KEY`
17All access to the base Data Commons requires a key. Custom Data Commons instances have their own base URL and do not accept the base-service key.

Authentication

API key required. Obtain through https://apikeys.datacommons.org/.

Pass as query parameter: &key=YOUR_KEY

Or as header: X-API-Key: YOUR_KEY

All access to the base Data Commons requires a key. Custom Data Commons instances have their own base URL and do not accept the base-service key.

Raw lines 9 to 18
19## Key Endpoints

Key Endpoints

Raw lines 19 to 20
21### 1. Get Statistical Value (single observation)
22```
23GET /v2/observation
24```
25| Parameter | Required | Description |
26|-------------|----------|------------------------------------------------------------|
27| key | Yes | API key |
28| entity.dcids | Yes | Place DCID(s) (e.g., `country/USA`, `geoId/06`) |
29| variable.dcids| Yes | Statistical variable DCID(s) |
30| date | No | Specific date or `LATEST` |
31| select | Yes | Fields to select: `entity`, `variable`, `date`, `value` |
33Example:
34```
35https://api.datacommons.org/v2/observation?key=YOUR_KEY&entity.dcids=country/USA&variable.dcids=Count_Person&date=LATEST&select=entity&select=variable&select=date&select=value
36```

1. Get Statistical Value (single observation)

GET /v2/observation
ParameterRequiredDescription
keyYesAPI key
entity.dcidsYesPlace DCID(s) (e.g., country/USA, geoId/06)
variable.dcidsYesStatistical variable DCID(s)
dateNoSpecific date or LATEST
selectYesFields to select: entity, variable, date, value

Example:

https://api.datacommons.org/v2/observation?key=YOUR_KEY&entity.dcids=country/USA&variable.dcids=Count_Person&date=LATEST&select=entity&select=variable&select=date&select=value
Raw lines 21 to 37
38### 2. Get Statistical Time Series
39```
40GET /v2/observation
41```
42Use same endpoint but omit `date` parameter (or set `date=''`) to get the full time series.
44Example (population time series for USA):
45```
46https://api.datacommons.org/v2/observation?key=YOUR_KEY&entity.dcids=country/USA&variable.dcids=Count_Person&select=entity&select=variable&select=date&select=value
47```

2. Get Statistical Time Series

GET /v2/observation

Use same endpoint but omit date parameter (or set date='') to get the full time series.

Example (population time series for USA):

https://api.datacommons.org/v2/observation?key=YOUR_KEY&entity.dcids=country/USA&variable.dcids=Count_Person&select=entity&select=variable&select=date&select=value
Raw lines 38 to 48
49### 3. Node Info (property values of an entity)
50```
51GET /v2/node
52```
53| Parameter | Required | Description |
54|-----------|----------|----------------------------------------------------|
55| key | Yes | API key |
56| nodes | Yes | DCID(s) of the node |
57| property | Yes | Property expression: `->prop` (out), `<-prop` (in)|
59Example (get properties of California):
60```
61https://api.datacommons.org/v2/node?key=YOUR_KEY&nodes=geoId/06&property=->*
62```
64Example (get name of a place):
65```
66https://api.datacommons.org/v2/node?key=YOUR_KEY&nodes=geoId/06&property=->name
67```

3. Node Info (property values of an entity)

GET /v2/node
ParameterRequiredDescription
keyYesAPI key
nodesYesDCID(s) of the node
propertyYesProperty expression: ->prop (out), <-prop (in)

Example (get properties of California):

https://api.datacommons.org/v2/node?key=YOUR_KEY&nodes=geoId/06&property=->*

Example (get name of a place):

https://api.datacommons.org/v2/node?key=YOUR_KEY&nodes=geoId/06&property=->name
Raw lines 49 to 68
69### 4. Supported V2 operations
71V2 provides `/observation`, `/node` and `/resolve`, each supporting GET and POST.
72It does not expose `/v2/sparql`. For graph queries outside these operations,
73consult the documented Data Commons BigQuery access.

4. Supported V2 operations

V2 provides /observation, /node and /resolve, each supporting GET and POST. It does not expose /v2/sparql. For graph queries outside these operations, consult the documented Data Commons BigQuery access.

Raw lines 69 to 74
75### 5. Resolve Entities (map names/coords to DCIDs)
76```
77GET /v2/resolve
78```
79| Parameter | Required | Description |
80|------------|----------|------------------------------------------------|
81| key | Yes | API key |
82| nodes | Yes | Entity identifiers to resolve |
83| property | Yes | `<-description` (name lookup) or coordinate-based |
85Example (resolve by name):
86```
87https://api.datacommons.org/v2/resolve?key=YOUR_KEY&nodes=California&property=<-description->dcid
88```

5. Resolve Entities (map names/coords to DCIDs)

GET /v2/resolve
ParameterRequiredDescription
keyYesAPI key
nodesYesEntity identifiers to resolve
propertyYes<-description (name lookup) or coordinate-based

Example (resolve by name):

https://api.datacommons.org/v2/resolve?key=YOUR_KEY&nodes=California&property=<-description->dcid
Raw lines 75 to 89
90### 6. Search for statistical variables
92Use `/v2/resolve` with `resolver=indicator` and `nodes` containing a natural-language
93description. Resolve returns candidate DCIDs and match metadata; inspect the
94candidates and variable definitions before retrieving observations.
96```bash
97# Illustrative authenticated request
98curl --fail-with-body --get 'https://api.datacommons.org/v2/resolve' \
99 -H "X-API-Key: $DATACOMMONS_API_KEY" \
100 --data-urlencode 'nodes=unemployment rate' --data-urlencode 'resolver=indicator'
101```

6. Search for statistical variables

Use /v2/resolve with resolver=indicator and nodes containing a natural-language description. Resolve returns candidate DCIDs and match metadata; inspect the candidates and variable definitions before retrieving observations.

# Illustrative authenticated request
curl --fail-with-body --get 'https://api.datacommons.org/v2/resolve' \
  -H "X-API-Key: $DATACOMMONS_API_KEY" \
  --data-urlencode 'nodes=unemployment rate' --data-urlencode 'resolver=indicator'
Raw lines 90 to 102
103## Common DCIDs
105### Places
106| DCID | Description |
107|-------------------|----------------------|
108| country/USA | United States |
109| country/GBR | United Kingdom |
110| country/CHN | China |
111| geoId/06 | California |
112| geoId/0667000 | San Francisco city |
113| geoId/06085 | Santa Clara County |

Places

DCIDDescription
country/USAUnited States
country/GBRUnited Kingdom
country/CHNChina
geoId/06California
geoId/0667000San Francisco city
geoId/06085Santa Clara County
Raw lines 105 to 114
115### Statistical Variables
116| DCID | Description |
117|-----------------------------------------|--------------------------------|
118| Count_Person | Total population |
119| Count_Person_Employed | Employed persons |
120| UnemploymentRate_Person | Unemployment rate |
121| Median_Income_Person | Median income |
122| Amount_EconomicActivity_GrossDomesticProduction_Nominal | Nominal GDP |
123| Mean_ConsumerPriceIndex | Consumer price index |
124| Count_Death | Number of deaths |
125| Count_Person_BelowPovertyLevelInThePast12Months | Persons in poverty |
126| Median_Age_Person | Median age |

Statistical Variables

DCIDDescription
Count_PersonTotal population
Count_Person_EmployedEmployed persons
UnemploymentRate_PersonUnemployment rate
Median_Income_PersonMedian income
Amount_EconomicActivity_GrossDomesticProduction_NominalNominal GDP
Mean_ConsumerPriceIndexConsumer price index
Count_DeathNumber of deaths
Count_Person_BelowPovertyLevelInThePast12MonthsPersons in poverty
Median_Age_PersonMedian age
Raw lines 115 to 127
128## Response Format

Response Format

Raw lines 128 to 129
130### Observation response
131```json
133 "byVariable": {
134 "Count_Person": {
135 "byEntity": {
136 "country/USA": {
137 "orderedFacets": [
138 {
139 "facetId": "2176550201",
140 "observations": [
141 {
142 "date": "2020",
143 "value": 331449281
144 },
145 {
146 "date": "2021",
147 "value": 331893745
148 }
149 ]
150 }
151 ]
152 }
153 }
154 }
155 },
156 "facets": {
157 "2176550201": {
158 "importName": "CensusACS5YearSurvey",
159 "provenanceUrl": "https://www.census.gov/",
160 "measurementMethod": "CensusACS5yrSurvey"
161 }
162 }
164```

Observation response

{
  "byVariable": {
    "Count_Person": {
      "byEntity": {
        "country/USA": {
          "orderedFacets": [
            {
              "facetId": "2176550201",
              "observations": [
                {
                  "date": "2020",
                  "value": 331449281
                },
                {
                  "date": "2021",
                  "value": 331893745
                }
              ]
            }
          ]
        }
      }
    }
  },
  "facets": {
    "2176550201": {
      "importName": "CensusACS5YearSurvey",
      "provenanceUrl": "https://www.census.gov/",
      "measurementMethod": "CensusACS5yrSurvey"
    }
  }
}
Raw lines 130 to 165
166### Node response
167```json
169 "data": {
170 "geoId/06": {
171 "arcs": {
172 "name": {
173 "nodes": [
174 {
175 "value": "California"
176 }
177 ]
178 }
179 }
180 }
181 }
183```

Node response

{
  "data": {
    "geoId/06": {
      "arcs": {
        "name": {
          "nodes": [
            {
              "value": "California"
            }
          ]
        }
      }
    }
  }
}
Raw lines 166 to 184
185### Resolve and pagination
187Resolve responses contain `entities`, each with the input `node` and a list of
188`candidates`. For any paginated V2 response, repeat the same request with its
189`nextToken` until no continuation token remains. Keep facet provenance with
190observations; dates, units and measurement methods can differ across facets.

Resolve and pagination

Resolve responses contain entities, each with the input node and a list of candidates. For any paginated V2 response, repeat the same request with its nextToken until no continuation token remains. Keep facet provenance with observations; dates, units and measurement methods can differ across facets.

Raw lines 185 to 191
192## Rate Limits
194- Base-service requests require an API key; quota depends on the issued key.
195- With API key: not formally published, but generally generous for normal use.
196- Implement client-side throttling (1-2 requests/second recommended).
197- Bulk data available via the Data Commons data download for large-scale analysis.

Rate Limits

  • Base-service requests require an API key; quota depends on the issued key.
  • With API key: not formally published, but generally generous for normal use.
  • Implement client-side throttling (1-2 requests/second recommended).
  • Bulk data available via the Data Commons data download for large-scale analysis.
Raw lines 192 to 198
199## Notes
201- The V2 API (paths starting with `/v2/`) is the current recommended version.
202- Older V1 endpoints (`/v1/bulk/observations/series`, `/stat/value`, etc.) still work but are deprecated.
203- DCID = Data Commons Identifier. Every entity, statistical variable, and concept has a unique DCID.
204- The knowledge graph includes data from US Census, World Bank, CDC, BLS, FBI, and many other sources.
206Official contracts: [V2](https://docs.datacommons.org/api/rest/v2/), [resolve](https://docs.datacommons.org/api/rest/v2/resolve.html).

Notes

  • The V2 API (paths starting with /v2/) is the current recommended version.
  • Older V1 endpoints (/v1/bulk/observations/series, /stat/value, etc.) still work but are deprecated.
  • DCID = Data Commons Identifier. Every entity, statistical variable, and concept has a unique DCID.
  • The knowledge graph includes data from US Census, World Bank, CDC, BLS, FBI, and many other sources.

Official contracts: V2, resolve.

Raw lines 199 to 206