africaAPI

Reference

Data

Query African indicators, latest values, and time series 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

Use /v1/countries/{country_code}/signals instead when you want a compact latest snapshot without composing the query yourself.

Common category values now include:

  • demographics
  • economy
  • infrastructure
  • energy
  • climate
  • health
  • education
  • agriculture
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"

Agriculture Query Example

curl "https://api.africa-api.com/v1/data?country_code=ng&metric_key=maize_production_tonnes&start_year=2020&end_year=2024" \
  -H "Authorization: Bearer $AFRICA_API_KEY"

Energy Query Example

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

Climate Query Example

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

Transport Query Example

curl "https://api.africa-api.com/v1/data?country_codes=eg,ke,za&metric_key=air_transport_passengers&year=2023" \
  -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

Common Query Patterns

  • Use country_code when you need one country.
  • Use country_codes when you need a comparison set.
  • Use latest=true when you only need the most recent observation per metric.
  • Use source= when your application needs a specific dataset instead of the default canonical result.

On this page