Command line

Everything in the package also works from a terminal, for scripts and quick checks:

undata search "maternal mortality"
undata latest 3.1.1 LDCs --within 10 --to mmr.xlsx
undata totals 3.1.1 World LDCs --latest

Errors print a plain message and exit with status 1; data warnings print as notes. The help below is generated from the command itself.

undata

usage: undata [-h] [--version] command ...

UN data without the guessing: statistics from the UN System Data Commons.

positional arguments:
  command
    search      find indicators by what they measure
    about       what an indicator is and how much data exists
    get         values for every year, or a range of years
    latest      each place's most recent value
    totals      the official figure for a region or group
    change      the difference between two years
    countries   list countries, all or in one region
    regions     list the regions and groups
    sdg         walk the SDGs: goals, then 16, 16.1, 16.1.2
    powerquery  Power Query (M) code for Power BI or Excel
    cache       manage the on-disk cache

options:
  -h, --help    show this help message and exit
  --version     show program's version number and exit

Places can be country names, ISO codes, regions ("Southern Asia") or groups
(LDCs, LLDCs, SIDS). Indicators can be ids or SDG numbers such as 3.1.1.

undata about

usage: undata about [-h] indicator

positional arguments:
  indicator

options:
  -h, --help  show this help message and exit

undata get

usage: undata get [-h] [--to FILE] [--describe] [--years YEARS] [--by BY]
                  [--wide]
                  indicator places [places ...]

values for every year, or a range of years

positional arguments:
  indicator      indicator id or SDG number; several with commas
  places         countries, regions or groups

options:
  -h, --help     show this help message and exit
  --to FILE      save to .xlsx or .csv instead of printing
  --describe     add sentences for a report
  --years YEARS  a year (2020) or a range (2015-2023)
  --by BY        a breakdown, such as sex or age
  --wide         one column per indicator

undata latest

usage: undata latest [-h] [--to FILE] [--describe] [--within WITHIN]
                     [--since SINCE] [--coverage] [--wide]
                     indicator places [places ...]

each place's most recent value

positional arguments:
  indicator        indicator id or SDG number; several with commas
  places           countries, regions or groups

options:
  -h, --help       show this help message and exit
  --to FILE        save to .xlsx or .csv instead of printing
  --describe       add sentences for a report
  --within WITHIN  latest value from the past N years only
  --since SINCE    leave out values older than this year
  --coverage       add who has data, and how old
  --wide           one column per indicator

undata totals

usage: undata totals [-h] [--to FILE] [--describe] [--years YEARS] [--latest]
                     indicator places [places ...]

the official figure for a region or group

positional arguments:
  indicator      indicator id or SDG number; several with commas
  places         countries, regions or groups

options:
  -h, --help     show this help message and exit
  --to FILE      save to .xlsx or .csv instead of printing
  --describe     add sentences for a report
  --years YEARS  a year (2020) or a range (2015-2023)
  --latest       only the most recent value

undata change

usage: undata change [-h] [--to FILE] [--describe] --start START --end END
                     indicator places [places ...]

the difference between two years

positional arguments:
  indicator      indicator id or SDG number; several with commas
  places         countries, regions or groups

options:
  -h, --help     show this help message and exit
  --to FILE      save to .xlsx or .csv instead of printing
  --describe     add sentences for a report
  --start START
  --end END

undata countries

usage: undata countries [-h] [region]

positional arguments:
  region

options:
  -h, --help  show this help message and exit

undata regions

usage: undata regions [-h]

options:
  -h, --help  show this help message and exit

undata sdg

usage: undata sdg [-h] [number]

positional arguments:
  number      a goal, target or indicator number

options:
  -h, --help  show this help message and exit

undata powerquery

usage: undata powerquery [-h] [--years YEARS] indicator places [places ...]

positional arguments:
  indicator
  places

options:
  -h, --help     show this help message and exit
  --years YEARS  a year (2020) or a range (2015-2023)

undata cache

usage: undata cache [-h] {clear}

positional arguments:
  {clear}

options:
  -h, --help  show this help message and exit