Course 2 · Python
UN data in Python, without the guessing.
Type a country's name and get a table with its source on every row. It is made for colleagues who need numbers for a report, with no API to learn first.
pip install undata import undata as un
table = un.latest("3.1.1", ["Bangladesh", "Viet Nam"])
un.save(table, "maternal-mortality.xlsx") | country | year | value | unit | source |
|---|---|---|---|---|
| Bangladesh | 2023 | 115 | Count per 100,000 live births | SDG Global Database |
| Viet Nam | 2023 | 47.6 | Count per 100,000 live births | SDG Global Database |
Two courses
All 11 undata videosCourse 3 · Python + Office
Present it in the tools you use
The functions you'll use most
Full API reference ↗Countries go in the way you'd write them in an email ("Viet Nam", "Vietnam", "VNM"), or as a region or UN group: "Southern Asia", "LDCs", "SIDS". An SDG number such as "3.1.1" works wherever one series reports it.
-
un.search("words") -
un.get(indicator, countries, years) -
un.latest(indicator, countries) -
un.totals(indicator, ["World", "LDCs"]) -
un.progress(indicator, countries, target=70) -
un.profile(country, indicators) -
un.gap(indicator, countries, by="sex") -
un.chart(table) -
un.save(table, "file.xlsx") -
un.cite(table)
Use it from an AI assistant
undata is also a connector for AI assistants (an MCP server): an assistant such as Claude can search UN indicators, fetch data and run the analyses itself, with the sources, years and gaps in every answer. It needs uv.
claude mcp add undata -- uvx --from "undata[mcp]" undata-mcp {
"mcpServers": {
"undata": { "command": "uvx", "args": ["--from", "undata[mcp]", "undata-mcp"] }
}
} 12 requests from UN work
See each with its output ↗Each is a short script that ends with a sentence ready for the report. Every one runs in Google Colab, and runs against the live platform every night.
- A briefing note: Chad against its Sahel neighbours
- Maternal mortality in Southern Asia since 2015, against the Target 3.1 level
- Women in parliament in Eastern Africa: who has passed 30%, who reached parity
- Refugees by country of origin, in number and per person
- Conflict deaths against homicide, and who reports at all
- One statistic, three agencies, two numbers: what to cite
- A regional data pack in Excel, with citations and gaps on their own sheets
- A dashboard file that refreshes itself on a schedule
- Checking what data.un.org's search box decided before sharing its chart
- Which least developed countries are on track for 2030, by the UN method
- Chad against Middle Africa and the world, on one chart
- The rural-urban gap in finishing primary school