Skip to content
Field Guide

Recipe Builder

From a question to the code that answers it

Search the platform's own resolver for an indicator, check how many places it really covers, then take the call in curl, Python, Power Query M, R, Julia or jq.
01

Find the indicator

Searches data.un.org as you would
Or pick from the checked shortlist
  • GDP per capita, current US dollarsundata/unicef/SPP_GDPPC
  • Conflict-related deaths per 100,000 populationundata/sdg/VC_DTH_TOTR
02

Say what you are drawing

This picks the endpoint for you
03

Check what it covers, before you build anything

Runs the real call

Two indicators from two agencies rarely cover the same countries. This runs the real request for each and reports how many places answered — and how many survive the join.

04

Take the code

Same request, six tools

Your call

GET /core/api/v2/observation

One value per place across a whole region. The containment expression is evaluated inside the graph, so this is one request rather than a loop over country codes.

curl
curl -s -G 'https://unsd-datacommons.gcp.un-icc.cloud/core/api/v2/observation' \
  --data-urlencode 'date=LATEST' \
  --data-urlencode 'variable.dcids=undata/unicef/SPP_GDPPC' \
  --data-urlencode 'variable.dcids=undata/sdg/VC_DTH_TOTR' \
  --data-urlencode 'entity.expression=Earth<-containedInPlace+{typeOf:Country}' \
  --data-urlencode 'select=date'     \
  --data-urlencode 'select=value'    \
  --data-urlencode 'select=variable' \
  --data-urlencode 'select=entity' \
| jq '[.byVariable | to_entries[]
       | {variable: .key,
          places: (.value.byEntity | with_entries(select(.value.orderedFacets)) | length)}]
      as $each
    | [.byVariable[] | .byEntity | with_entries(select(.value.orderedFacets)) | keys] as $sets
    | {each: $each, both: ($sets[0] - ($sets[0] - $sets[1]) | length)}'

# An inner join across two agencies keeps only the places that have
# both. Print the three counts before you plot: the join is where
# countries disappear, and it never says so.
# Drop the jq filter to get the observations themselves. The arrows and braces
# must reach the server percent-encoded, which is what --data-urlencode does;
# a hand-built URL returns 400.

↑ ↓ to move · Enter to open · A match inside a video opens the lesson at the moment the words are said.