africaAPI

Start Here

Authentication

Authenticate Africa API requests with bearer tokens, create API keys in the dashboard, and understand which routes are public.

API Keys

Create and manage API keys in the dashboard.

Protected requests use:

Authorization: Bearer <api_key>

Public routes

  • GET /health
  • GET /v1/platform/version

Protected routes

All current data-bearing /v1/* routes require:

Authorization: Bearer <api_key>

Do not assume read routes are public. Countries, signals, indicators, data, markets, trade, government, and policy routes all require an API key.

Request Format

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

Implementation Guidance

  1. Always send the Authorization header from your first protected request.
  2. Store API keys server-side for production workloads.
  3. Use separate keys per environment.
  4. Rotate keys on any suspected exposure.
  5. Never embed production keys in public client-side code.

JavaScript Pattern

const response = await fetch(
  "https://api.africa-api.com/v1/indicators?category=health&has_data=true",
  {
    headers: {
      Authorization: `Bearer ${process.env.AFRICA_API_KEY ?? ""}`,
    },
  },
);

Expected Auth Errors

StatusMeaning
401Missing or invalid bearer token
403Authenticated but not permitted for the attempted action

See Errors for full handling guidance.

On this page