Skip to content
Field Guide

Scenarios · 14 minutes

Start from the question, not from the endpoint

Three requests as they actually arrive, worked end to end: how the identifier was found, which of the three endpoints answers, the code in six tools, and the thing the data does that the question did not anticipate. The dead ends are left in, because a discovery trail with the failures edited out teaches nobody how to search.

First, the part nobody documents: how do you find the thing to call?

There are three endpoints and about 85,000 identifiers. The endpoint is never the problem.
01Seconds

Start with the shortlist

Twenty indicators, checked for coverage, in the Data Finder. If your question is one of the common ones you are already finished.

Works for maybe a third of requests.

02A minute

Then the search box

The platform’s own resolver, which is what the Prompt Lab and step 1 of the builder below both call. Read the whole result list rather than taking the top hit — the right answer is often fourth or eighth.

Good for common concepts. Returns nothing at all for some ordinary topics.

03Five minutes

Then walk the graph

Descend from a collection or an SDG goal to the leaf. Slower, and exact: it cannot return a plausible wrong answer, and it shows you the variants of your indicator you did not know existed.

Always works. This is the rung to reach for when search disappoints.

The walk, as five commands

Two relation expressions do all of it. <-specializationOf descends one level of the hierarchy; <-memberOf returns the leaves you can request observations for. Every level looks the same, so this is five variations on one command rather than five things to learn.

collection → indicator → group → leaf
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 contributing collections
walk undata/g/sdgf/goal-16          # or start from an SDG goal
walk undata/g/sdgf/target-16-1      # its indicators — note "ind", not "indicator"
walk undata/g/sdgf/ind-16-1-2       # the variants: counts, rates, civilian, unknown
walk undata/g/sdg/VC_DTH_TOTR.000 '<-memberOf'   # the fetchable leaf

Run those five lines and you have watched the whole discovery problem dissolve. The fourth walk is the one that pays: it reveals that conflict deaths are published as a rate as well as a count, which changes the chart you were about to draw.

Build your own, against the live platform

Search for an indicator, say what you are drawing, measure what it covers, and take the code in your tool. Everything here is a real request from your browser to data.un.org.
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.

Scenario 1 — Can I get conflict deaths against GDP per capita, as a scatter?

Two indicators, two agencies, one scatter plot. The API part takes four minutes. Finding the two identifiers takes longer, and the answer to the question turns out to be that this chart should not be drawn at all — which the data tells you in one line, if you ask it before you plot.

Asked by: A colleague preparing a background note, who has seen the chart elsewhere

Finding the identifier7 steps, failures included

  1. 01Ask the platform search box for GDP per capita, the way you would ask a person.Near miss

    Eleven variables. Today the one you want happens to be first — but nothing on the page tells you that, and the ten beneath it are a minefield: an annual growth rate rather than a level (WHO), gross national income rather than GDP and silently sliced to Sex=Male (UNDP), gross domestic product at current prices (UNIDO — a total, not a per-capita), the HDI itself, and real GDP per worker at PPP (ILO), which is per worker and not per head. A day earlier this same query put the right answer eighth. The resolver also silently committed to the United States, because the question named no place.

  2. 02Read what the top hit actually is, rather than trusting that it is top. The full name is the only thing that settles it.Found it

    undata/unicef/SPP_GDPPC — "Gross Domestic Product (GDP) per capita (current United States dollars)". Published inside the UNICEF collection, which is not where anyone would have looked for it. Rank is the part that moves between days; the name and the dcid are the parts that do not.

  3. 03Now ask the same search box for conflict-related deaths.Dead end

    No variables at all. The resolver returns a place — the United States again — and an empty variable list. For this topic the search box is not a tool you can build on.

  4. 04Switch to walking the SDG framework, which is exact. Conflict deaths are SDG 16.1.2, so start at the goal and descend.Found it

    Twelve targets. 16.1 is "significantly reduce all forms of violence and related death rates everywhere" — undata/g/sdgf/target-16-1.

  5. 05Descend again, to the indicators under that target.Found it

    Four indicators, and the identifier is undata/g/sdgf/ind-16-1-2 — "ind", not "indicator". Guessing the longer spelling returns an empty response with no error, which is the whole argument against constructing identifiers by analogy.

  6. 06Descend once more. This is the rung that changes the analysis.Found it

    Six groups, not one: total deaths, civilian, non-civilian, unknown — and two rates. undata/g/sdg/VC_DTH_TOTR is "Number of total conflict-related deaths per 100,000 population". A rate exists. Plotting the raw count against income would mostly have plotted population size.

  7. 07Take the last step, from the group to the variable you can actually fetch.Found it

    undata/sdg/VC_DTH_TOTR. This is a leaf, and observations can be requested for it.

What you end up with

GDP per capita, current US dollars

undata/unicef/SPP_GDPPC

UNICEF collection · 210 countries · 2024 for every country — a genuine cross-section

Conflict-related deaths per 100,000 population

undata/sdg/VC_DTH_TOTR

SDG collection (indicator 16.1.2) · 14 countries · 2022, 2023 and 2024

The 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.

Then the data says something the question did not expect

210 countries, 14 countries, and every point you plot is a country at war

GDP per capita returns 210 countries. The conflict death rate returns 14. The inner join keeps 14, and those 14 are Afghanistan, the Central African Republic, DR Congo, Ethiopia, Iraq, Lebanon, Libya, Mali, Myanmar, the Palestinian Territories, the Philippines, South Sudan, Syria and Ukraine. Norway, Costa Rica and Japan are not zero on this indicator — they are absent from the response entirely, because a country with no conflict files no conflict-death return. A scatter of these two series cannot say anything about whether conflict and income are related across countries, because every peaceful country has been removed from the sample before the chart is drawn. The chart would not be imprecise. It would be answering a different question from the one asked.

So draw this instead

Draw it, but label it for what it is: among the fourteen countries reporting conflict deaths, how does the death rate vary with income. Put n = 14 in the title, log the income axis because it spans 353 to 7,330 dollars, and state the reference years — the rate is 2022, 2023 or 2024 depending on the country, against income that is uniformly 2024. If the question really was about conflict and income across all countries, the honest answer is that this platform cannot support it, and the note should say so rather than showing fourteen dots.

Scenario 2 — My office reports on SDG 16.1. What can I actually show for our region?

This is the friendliest version of the discovery problem, because the SDG framework is in the graph as a branch you can walk. You start from the target your mandate names and finish with a list of leaf variables, without guessing anything.

Asked by: A reporting officer with a target number and no identifiers

Finding the identifier2 steps, failures included

  1. 01Walk from the target to its indicators.Found it

    Four: 16.1.1 intentional homicide per 100,000, 16.1.2 conflict-related deaths, 16.1.3 population subjected to violence, 16.1.4 feeling safe walking alone after dark.

  2. 02Check coverage before choosing, not after. Ask each candidate for the whole region at once.Found it

    16.1.1 returns 37 African countries. 16.1.2 returns 6. For a regional page, the homicide indicator is the one that can carry a map; the conflict indicator can carry a sentence about six countries and nothing more.

What you end up with

Intentional homicide rate per 100,000 population

undata/unodc/VIC_HOM_RT

UNODC · 37 countries · 2009 to 2025 — eleven distinct years across the region

The 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/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.
# --data-urlencode is what does that; a hand-built URL returns 400.

Then the data says something the question did not expect

Good coverage, eleven different reference years

Thirty-seven countries is enough for a regional ranking. But date=LATEST resolves per country, and across those 37 the newest available year ranges from 2009 to 2025. That is not a cross-section, and a map coloured from it compares a figure from before the Arab Spring with one from this year. Either pin a year and accept the countries that drop out, or keep LATEST and label every value with its own year.

So draw this instead

A sorted horizontal bar chart with the reference year printed on each bar, not a choropleth. A map cannot show the year per country, so it hides exactly the thing that makes this ranking questionable.

Scenario 3 — I need electricity access for our five programme countries, 2000 to now.

The easy case, included because most requests are this one and it is worth seeing what "easy" looks like: one request, no discovery, no trap beyond remembering that a gap is not a zero.

Asked by: Almost everyone, most weeks

Finding the identifier1 step, failures included

  1. 01Skip the API. This indicator is on the shortlist in the Data Finder, already checked for coverage.Found it

    undata/sdg/EG_ACS_ELEC — SDG 7.1.1, access to electricity as a percentage of population. 217 countries, all reporting 2024.

What you end up with

Access to electricity, % of population

undata/sdg/EG_ACS_ELEC

SDG collection (indicator 7.1.1) · 217 countries · 2024 for every country

The call

POST /api/observations/series

A trend needs every observation for places you can name, which is what the series endpoint returns. It takes no date argument: you get the whole history and slice it yourself.

curl
curl -s -X POST 'https://unsd-datacommons.gcp.un-icc.cloud/api/observations/series' \
  -H 'Content-Type: application/json' \
  -d '{"variables":["undata/sdg/EG_ACS_ELEC"],"entities":["country/BGD", "country/ETH", "country/IND", "country/KEN", "country/SSD"]}'

# The body must stay on one line: a line break anywhere inside it makes this
# deployment answer 403 Forbidden, which reads like an auth problem and is not.

Then the data says something the question did not expect

Nothing goes wrong, and that is worth knowing too

A modelled series published annually for almost every country gives you a dense, uniform result. The only care needed is at the edges: a country that has not reported comes back with an empty series rather than a row of zeros, and the chart must draw that as a gap. This is the shape of request the platform is best at, and it is most of them.

So draw this instead

A line chart from a zero baseline, because this is a bounded percentage approaching a ceiling and the distance from 100 is the story.

What these three have in common

Takeaway

The endpoint is decided by the shape. Trend over named places is the series endpoint. One value across a region is REST v2 with a containment expression. There is no third decision, which is why the builder makes it for you.

Takeaway

Search is a shortcut, not a method. It buried GDP per capita at position eight and returned nothing at all for conflict deaths. The graph walk found both, plus a rate variant that changed the analysis.

Takeaway

Count before you chart. One line — how many places does each indicator return, and how many survive the join — is the difference between a defensible figure and a chart that answers a question nobody asked.

Takeaway

Absence has a pattern. The countries missing from a series are rarely a random sample. When the missing ones are missing for a reason connected to what you are measuring, the join has chosen your sample for you.

The same scenarios worked inside a tool: Power BI and Tableau, or Python, R and Julia. For the endpoints themselves, the query cookbook.

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