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 /healthGET /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
- Always send the
Authorizationheader from your first protected request. - Store API keys server-side for production workloads.
- Use separate keys per environment.
- Rotate keys on any suspected exposure.
- 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
| Status | Meaning |
|---|---|
401 | Missing or invalid bearer token |
403 | Authenticated but not permitted for the attempted action |
See Errors for full handling guidance.