The REST surface, in the order you will need it
Graph and observations (REST v2)
https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/node · /observation · /resolve
Convenience endpoints (website API)
https://unsd-datacommons.gcp.un-icc.cloud/api/observations/series · /place/name · /variable-group/info
First, learn the identifier grammar
- Undisaggregated parent
- undata/sdg/VC_DTH_TOTN
- Dimension filters
- AGE = Y0T17, SEX = F
- Contributing collection
- Global SDG Indicators Database
- Rebuilt from its parts
- identical ✓
Recipe 0 — Find the identifier, which is the only hard part
API=https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/node
walk () { curl -s -G "$API" --data-urlencode "nodes=$1" \
--data-urlencode "property=${2:-<-specializationOf}"; }
walk undata/g/Root # the 16 collections
walk undata/g/sdgf/goal-16 # or start at an SDG goal
walk undata/g/sdgf/target-16-1 # its indicators — "ind", not "indicator"
walk undata/g/sdgf/ind-16-1-2 # counts, rates, civilian, unknown
walk undata/g/sdg/VC_DTH_TOTR.000 '<-memberOf' # the fetchable leaf- Try the platform's search first — it is instant and often right. But read the whole result list rather than the top hit: for “GDP per capita” the correct variable is eighth, and it lives in the UNICEF collection.
- Search returns nothing at all for some ordinary topics — conflict-related deaths among them. That is an answer, not an outage, and it is the signal to walk.
- The walk shows you variants you did not know to ask for. Conflict deaths exist as a count and as a rate per 100,000 — and only one of those belongs on an axis against income.
- Never construct an identifier by analogy.
indicator-16-1-2looks right and returns an empty response; the real segment isind-16-1-2.
The scenarios page runs this ladder three times against real requests, with the dead ends left in, and has a builder that searches, measures coverage and emits the call in six tools.
Recipe 1 — A time series for known places
When: You know the indicator and the countries, and you want every year.
curl -s -X POST \
'https://unsd-datacommons.gcp.un-icc.cloud/api/observations/series' \
-H 'Content-Type: application/json' \
-d '{"variables":["undata/sdg/VC_DTH_TOTN"],"entities":["country/SSD","country/COD","country/SYR"]}'
# The body is on one line deliberately. A line break anywhere inside it
# makes this deployment answer 403 — see trap 1 below.- Several variables and several entities in one call: you get the cross product.
- Each block carries a facet id; look it up in the top-level
facetsobject for the source URL, unit and observation period. - An entity that returns an empty
serieshas no data — which is not the same as zero.
Recipe 2 — One value per country across a whole region
When: You want a ranking or a map, and you do not want to enumerate country codes.
curl -s -G \
'https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/observation' \
--data-urlencode 'date=LATEST' \
--data-urlencode 'variable.dcids=undata/unodc/VIC_HOM_RT' \
--data-urlencode \
'entity.expression=africa<-containedInPlace+{typeOf:Country}' \
--data-urlencode 'select=date' \
--data-urlencode 'select=value' \
--data-urlencode 'select=variable' \
--data-urlencode 'select=entity'- The arrows and braces must reach the server percent-encoded — which is exactly what --data-urlencode and URLSearchParams do for you.
- Swap
africafor any of the 30 UN geographic regions: SouthernAsia, EasternAfrica, LatinAmericaAndCaribbean, Melanesia, and so on. - date=LATEST resolves per entity, so the result can mix reference years. Always check the spread before calling it a cross-section.
Recipe 3 — Pin an exact year, or a range
When: You need a comparable cross-section rather than “whatever is newest”.
# a single year, identical for every country
curl -s -G \
'https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/observation' \
--data-urlencode 'date=2023' \
--data-urlencode 'variable.dcids=undata/undphdro/HDI_hdi' \
--data-urlencode \
'entity.expression=SouthernAsia<-containedInPlace+{typeOf:Country}' \
--data-urlencode 'select=date' \
--data-urlencode 'select=value' \
--data-urlencode 'select=entity'- Pinning the year is how you get a defensible like-for-like comparison.
- The trade-off is coverage: countries that have not reported that year drop out entirely rather than falling back to an older reading.
- Omitting
datereturns the full series instead of a point.
Recipe 4 — Discover what exists, instead of guessing
When: You have a topic but no identifier, and you would rather walk the tree than trust a search ranking.
# the 16 contributing collections and their sizes
curl -s -X POST \
'https://unsd-datacommons.gcp.un-icc.cloud/api/variable-group/info' \
-H 'Content-Type: application/json' \
-d '{"dcid": "undata/g/Root", "entities": []}'
# drill into one collection
curl -s -G \
'https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/node' \
--data-urlencode 'nodes=undata/g/unodc' \
--data-urlencode 'property=<-specializationOf'
# and finally the fetchable leaf variables of a group
curl -s -G \
'https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/node' \
--data-urlencode 'nodes=undata/g/unodc/VIC_HOM_RT.000' \
--data-urlencode 'property=<-memberOf'<-specializationOfdescends the hierarchy;<-memberOfreturns the leaf variables you can actually request observations for.- The tree is deeper than it looks: collection → indicator → dimension-sliced group → leaf. Do not stop at the first level and assume you have found a variable.
- Useful roots:
undata/g/Root(collections),dc/g/UN(the 12 thematic areas),undata/g/sdgf/goal-16(an SDG goal).
Recipe 5 — Inspect a variable's metadata before you trust it
When: Before publishing anything: confirm what the series actually measures.
curl -s -G \
'https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/node' \
--data-urlencode 'nodes=undata/sdg/VC_DTH_TOTN' \
--data-urlencode 'property=->*'->*returns every outgoing property of the node: name, population type, measured property, units and the statistical classifications it belongs to.- This is where you find out that two similarly named indicators differ in denominator, or that a "rate" is per 1,000 rather than per 100,000.
- The
facetsobject on any observation response carries the provenance URL — follow it for the methodology and terms of use.
Recipe 6 — Turn a name into a dcid, and read the ambiguity
When: You have a place name from a colleague, a spreadsheet or a filename, and you need the identifier the API actually takes.
curl -s -G \
'https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/resolve' \
--data-urlencode 'nodes=Kenya' \
--data-urlencode 'property=<-description->dcid'- Returns
{"entities":[{"node":"Kenya","candidates":[{"dcid":"country/KEN"}]}]}. ISO codes work too —KENresolves to the same thing — and<-wikidataId->dcidtakesQ114. - The
propertyexpression must have two parts, an incoming and an outgoing arc. A one-part expression like->dcidreturns 400 with a message that says so. - Read
candidatesas a list, not a value.Georgiareturns three, andgeoId/13— the US state — ranks abovecountry/GEO. Same default-to-America bias the search box has. - A 500 here means "not in the index", not "server broken": a miss falls through to a geocoder that is disabled on this deployment. One typo —
Kenyaa— answers 500, and so does passing a dcid instead of a name. - One unresolvable name fails the whole batch, so resolve names one at a time if any of them are user-supplied.
Recipe 7 — Page past the first 500 results
When: Any time you walk the graph to find out how much of something exists. This is the quietest wrong answer in the API.
# page 1 — returns 500 nodes and a nextToken
curl -s -G \
'https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/node' \
--data-urlencode 'nodes=africa' \
--data-urlencode 'property=<-containedInPlace'
# page 2 — hand the token straight back
curl -s -G \
'https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/node' \
--data-urlencode 'nodes=africa' \
--data-urlencode 'property=<-containedInPlace' \
--data-urlencode 'nextToken=PASTE_THE_TOKEN_HERE'- A node query is capped at 500 results. There is no error, no warning and no total — just a
nextTokenat the top level of the response that nothing obliges you to read. - Everything inside Africa is 2,739 nodes across 6 pages. Stop at page one and you have 500, which is not a sample of anything: it is whatever the index returned first.
- Loop until
nextTokenis absent. That absence is the only end-of-results signal you get. - Some walks are much larger than they look.
nodes=Earthwith the same property was still returning full pages after 12 requests, so bound the loop and hold the result rather than paging interactively. - The observation endpoints are not capped this way — a containment query like Recipe 2 returns every country in one response. It is the node walk that truncates.
Eight things that will trip you up
- 1
A line break in a POST body returns 403
Pretty-print a JSON payload and this deployment answers 403 Forbidden — on every POST route, including /mcp. Spaces and tabs are fine; one newline anywhere in the body, even a trailing one, is not. Because the API has no credentials at all, a 403 sends people hunting for an API key that does not exist. Keep bodies on one line: curl -d @file.json is safe (curl strips the newlines), curl --data-binary @file.json is not, requests(json=…) is safe, and json.dumps(…, indent=2) is not.
- 2
Relation expressions must be encoded
An unencoded
->or<-in a query string returns HTTP 400 with no useful message. Always build the query with URLSearchParams or --data-urlencode. - 3
/api/observations/pointdoes not existThe website API offers
series, notpoint— asking for point returns 405. Use the REST v2/observationendpoint withdate=LATESTfor single values. - 4
The bare indicator code may not be the total
Maternal mortality is only published as
undata/sdg/SH_STA_MORT.SEX--F; the unsuffixed dcid returns nothing. Confirm identifiers, never construct them by analogy. - 5
Empty is not zero
A requested entity with no observations is silently absent from the response body. Handle the missing key explicitly, or you will chart a data gap as a value.
- 6
Disaggregations exclude "unknown"
Age and sex slices omit the unknown category, which is carried separately (
.AGE--_U). Summing the named bands will not reproduce the total. - 7
There is no sub-national data, and the query for it still works
Ask for
{typeOf:AdministrativeArea1}inside Earth and you get 13 places — every one of them acountry/dcid. They are dependent territories double-classified as both Country and AdministrativeArea1: Hong Kong, Greenland, Guam, Bermuda, Gibraltar, Macau, the Caymans. All 13 report exactly 100% electricity access, so the chart you get is a flat line of small wealthy territories. Scope it to one country —country/IND<-containedInPlace+{typeOf:AdministrativeArea1}— and the response is an empty success. This is a country-level platform; treat any sub-national result as a classification artefact. - 8
The same indicator under two agencies is one source, not two
Maternal mortality appears as
undata/sdg/SH_STA_MORT.SEX--Fand asundata/unicef/MNCH_MMR.SEX--F, under different agencies with different provenance URLs. Across all 195 countries they carry identical coverage, identical years and identical values — 378.79578 against 378.8 for Kenya in 2023, the same estimate rounded differently. Finding an indicator twice is not corroboration, averaging the pair is circular, and joining them introduces variance that is pure rounding.
Where this goes next
Power BI & Tableau
The keyed record, turned into a rectangle
Power Query M for the call and the cleaning, the star schema worth building on top of it, two DAX measures, and why Tableau wants a file rather than a connector.
Python, R & Julia
The same two calls, three ways
A tidy frame with the provenance carried on every row, the empty-series branch written first, and the repeated-query-parameter trap that returns a bare 400 in every language.
A note on courtesy
There is no API key, which means there is no quota protecting the service from you. Cache what you fetch, batch your variables and entities into single requests rather than looping, prefer one containment expression over fifty country calls, and do not poll for data that updates annually.
This site practises what it recommends: one request per panel, and a committed snapshot so that a reader who reloads the page ten times does not cost the UN ten round trips per chart.