Documentation / Getting started
Getting started
Reference
Documentation
worldgovdata API
Comparative country statistics — governance, economy, health, climate and nine other topics — harmonised onto one country spine, served as JSON or CSV from a single versioned base URL.
Every endpoint is a GET. Browsing the catalogue is free. You only spend credits when rows of actual data come back.
The base URL
There is one public base URL, and it is the only one. Everything below is relative to it.
Base URL
https://api.worldgovdata.com/v1The version lives in the path. /v1 will not change shape underneath you: fields are added, never removed or renamed. A breaking change would arrive as /v2.
Sixty seconds
The catalogue endpoints need no credentials at all, so the first call works before you have an account. This one asks the country spine for South Asia.
No key required
curl -sS "https://api.worldgovdata.com/v1/countries?region=South%20Asia"Response · 200
Lines beginning // in the samples on this site mark where a real response was trimmed for reading. The API never returns comments.
To fetch observations rather than metadata you need a key. That is five minutes, and the quickstart walks the whole path — sign up, verify, create a key, make the first metered call, read the result.
The three things you need first
How a response is shaped
Every JSON response is the same two keys. data is the payload — an array for list endpoints, an object for detail endpoints. meta describes the request that produced it and always carries generated_at.
Success envelope
meta omits any field you did not send, so a key being absent means “not applied”, never “null”. Failures replace the whole body with a single error object:
Error envelope
Branch on error.code, never on error.message — the message is written for a human and may be reworded. Some codes add fields: a 402 carries required and balance, a 429 carries retry_after. The full list is on Errors.
What each route costs
Metadata is free and callable anonymously; the endpoints that return rows of observations cost credits. One credit is 100 rows.
| Route | Credits |
|---|---|
| GET /v1/countries | free |
| GET /v1/countries/{iso3} | 1 |
| GET /v1/indicators | free |
| GET /v1/indicators/{id} | free |
| GET /v1/topics | free |
| GET /v1/meta/freshness | free |
| GET /v1/meta/coverage | free |
| GET /v1/rankings/{indicator} | 1 |
| GET /v1/data | max(1, ceil(rows / 100)) |
| GET /v1/usage | free |
| GET /v1/ping | free |
A request that ends in an error costs nothing — including a too_many_rows rejection, which is counted before any data is read. New accounts get 2,000 credits at email verification. Full detail on Credits.
The data model, in four nouns
- Country — the spine. Keyed by ISO 3166-1 alpha-3 (
IND,CHN), carrying region, subregion, income group, M49 and the World Bank code. Every observation hangs off one of these. Reference - Indicator — one measured series, with an id like
wgi.control_of_corruption: a provider prefix, a dot, a slug. Carries its unit, topic, direction (higher_is_better), coverage and, critically, the licence and attribution you must display. Reference - Observation — one country, one indicator, one year, one value, sometimes a confidence interval. This is the atom, and
/v1/datais how you get them. Reference - Ranking — every country ordered on one indicator for one year, pre-computed, with the rank and the size of the ranked field. Reference
Topics group indicators into thirteen themes. Ask /v1/topics rather than hardcoding the list — it is data, and it grows.
Conventions
- Read-only. Every route is a GET. Anything else returns
405 method_not_allowed. - Ids are exact. Indicator ids are case-sensitive; ISO3 country codes are upper-cased for you.
- Cacheable — by you. An anonymous
/v1GET returnspublic, max-age=3600, s-maxage=21600. An authenticated one returnsprivate, no-store, because it carries your balance and your remaining quota and must not sit in a shared cache. Cache it in your own application anyway: behind this data are pipelines that run daily at fastest and annually at slowest, and a response you did not re-request costs no credit. - Compressed. Send
Accept-Encoding: gzipand responses over roughly half a kilobyte come back gzipped. Every HTTP client does this by default. - CORS is open, credentials are not. Any origin may call the API, but cookies are never accepted. Which is also why a key must never be in browser code — see Authentication.
- One hard cap. A single
/v1/datarequest will not return more than 100,000 rows. Pagination has the recipe for fetching more than that.
Before you publish anything
The data is not ours. Each indicator arrives under its provider’s licence — most commonly CC BY — and every response tells you which: meta.licence and meta.attribution on the data endpoints, data.licence and data.attribution on the indicator record.