Documentation / Endpoints
Getting started
Reference
Endpoints
Rankings
Every country ordered on one indicator for one year, pre-computed, with the rank and the size of the ranked field attached. A flat credit however many rows come back.
/v1/rankings/{indicator}- Auth
- Bearer key required
- Cost
- 1
- Returns
- Ranked rows for one year
- Order
- By rank, ascending
Base https://api.worldgovdata.com/v1
If what you want is a cross-section — every country, one year — this is both cheaper and more useful than the equivalent /v1/data query, because the ranking is already done.
Parameters
Parameters
| Parameter | Description |
|---|---|
indicatorpath, string · required | The indicator id. Exact and case-sensitive.example: wgi.control_of_corruption |
year"latest" or a 4-digit year | latest resolves to the most recent ranked year that is not a projection. Anything else must be four digits, or the request is a 400.default: latest · example: 2015 |
Example
Request
curl -sS "https://api.worldgovdata.com/v1/rankings/wgi.control_of_corruption" \
-H "Authorization: Bearer $WGD_API_KEY"Response · 200
Row fields
| Field | Type | Notes |
|---|---|---|
| iso3 | string | ISO 3166-1 alpha-3 country code. |
| country | string | Common English name, joined from the spine. A convenience — iso3 is the key. |
| value | number | null | The measurement the rank was computed from. |
| rank | integer | 1 is best, and “best” is defined by meta.higher_is_better. |
| n | integer | How many countries were ranked that year. The denominator for a percentile. |
| year | integer | The resolved year. Identical on every row. |
n is on every row and is the same on every row: the number of countries ranked that year. It is what makes ranks comparable across indicators — rank 40 of 213 and rank 40 of 61 are very different facts, and rank / n is the percentile that reconciles them.
How “latest” resolves
year=latest does not mean the newest year present. It means the newest ranked, non-projection year, and the cutoff is per indicator.
This matters because several providers ship forecast years inside the same series as their estimates — UN population projections run to 2100, IMF forecasts a few years ahead. A plain maximum would open a population league table on the year 2100. So latest is capped at the indicator’s own newest observed year, which is why a series the catalogue lists as updated in 2023 resolves to 2023 rather than to this calendar year.
- The resolved year is always in
meta.year. Read it rather than assuming. - Projection years remain reachable — ask for one explicitly with
?year=2050. They are simply never the default. - An indicator that is entirely projection still resolves, falling back to the newest year it has.
A specific year
curl -sS "https://api.worldgovdata.com/v1/rankings/wgi.control_of_corruption?year=2015" \
-H "Authorization: Bearer $WGD_API_KEY"Errors and empty results
400 bad_year—yearwas neitherlatestnor four digits.401 unauthorized— no key.402 insufficient_credits— balance below 1.404 indicator_not_found— no such id, or a series we may not redistribute.404 no_rankings— the indicator exists but has no ranked years at all. Series flaggedno_rankin the catalogue are never ranked; read their values from /v1/data instead.
Reading meta
indicator— echoed back.year— the resolved year, which is the only place to learn whatlatestmeant.higher_is_better— the direction. Nullable, for concepts with no better end.count— rows returned. Equal tonon the rows, except in the empty case.coverage—n_countries,yr_min,yr_max,latest_year. Omitted entirely when the indicator has no coverage row yet, so check for the key rather than for a null.licenceandattribution— the terms for this series.
Notes and gotchas
- Flat price. One credit whether the indicator ranks twelve countries or two hundred. For a whole-world cross-section this is dramatically cheaper than the same query through
/v1/data. - One year per request. There is no range. A rank-over-time view means one request per year — or pull the values from
/v1/dataand rank them yourself. - Only enabled countries appear. The spine join means a country we do not serve is absent from the ranking even if the provider ranked it.
- Display-tier indicators are served here. Displaying them is exactly what that tier permits. If you intend to redistribute, check
access_tieron the indicator record first — this response does not carry it. See Licensing. - Ties. Ranks come from the ranking mart, not from a sort you can influence. Two identical values receive the order the mart computed; do not build logic that assumes strictly increasing values down the list.
- Cache it yourself. A league table changes when its provider publishes — once a year for most of these. The response comes back
private, no-storebecause it is authenticated and carries your balance, so the cache has to be inside your application rather than in front of it.
Related
- /v1/indicators — find the id, and read
no_rank,higher_is_betterandcoveragebefore you spend anything. - /v1/countries/{iso3} — the same comparison from the other direction: one country, every indicator, with its rank attached.
- /v1/data — the underlying series.