africaAPI

Reference

Data

Query canonical indicator observations across countries, years, categories, and sources.

Canonical Observation Endpoint

GET/v1/data

/v1/data is the canonical read layer for country-level observations.

Use it for:

  • latest country metrics
  • time-series queries
  • multi-country comparisons
  • category-wide slices
  • source-specific reads

Common category values now include:

  • demographics
  • economy
  • infrastructure
  • health
  • education
country_codestring
One country code
country_codesstring
Comma-separated country codes
metric_keystring
One metric key
metric_keysstring
Comma-separated metric keys
categorystring
Indicator category filter
sourcestring
Source code filter
yearinteger
Exact year
start_yearinteger
Inclusive start year
end_yearinteger
Inclusive end year
latestboolean
Return only the latest observation per country and metric
limitinteger
Max rows to return (1-1000)
Request
curl "https://api.africa-api.com/v1/data" \
  -G \
  -d "country_code=ke" \
  -d "metric_key=population_total" \
  -d "start_year=2020" \
  -d "end_year=2024" \
  -H "Authorization: Bearer $AFRICA_API_KEY"
Response
{
  "data": [
    {
      "country_code": "ke",
      "country_name": "Kenya",
      "metric_key": "population_total",
      "metric_name": "Total Population",
      "year": 2020,
      "period": "annual",
      "value": 52217334,
      "unit": "persons",
      "source": "world_bank_wdi",
      "value_status": "reported",
      "retrieved_at": "2026-03-07T12:10:14Z"
    },
    {
      "country_code": "ke",
      "country_name": "Kenya",
      "metric_key": "population_total",
      "metric_name": "Total Population",
      "year": 2024,
      "period": "annual",
      "value": 55100586,
      "unit": "persons",
      "source": "world_bank_wdi",
      "value_status": "reported",
      "retrieved_at": "2026-03-07T12:10:14Z"
    }
  ],
  "meta": {
    "total": 5,
    "limit": 100
  }
}

Latest Multi-Country Query

curl "https://api.africa-api.com/v1/data?country_codes=ng,ke,za&metric_key=gdp_current_usd&year=2024" \
  -H "Authorization: Bearer $AFRICA_API_KEY"

Education Query Example

curl "https://api.africa-api.com/v1/data?country_code=ke&category=education&latest=true" \
  -H "Authorization: Bearer $AFRICA_API_KEY"

Canonical Source Behavior

When more than one source publishes the same metric, /v1/data returns one canonical observation by default. Use source= if you need to pin the response to a specific dataset.

Validation Rules

  • year cannot be combined with start_year or end_year
  • start_year must be less than or equal to end_year
  • limit is capped at 1000

On this page