Platform
SDKs
Use thin HTTP client wrappers for Africa API until official SDK packages ship.
Official SDK packages are not published yet. Use a small internal client so you can swap to an official SDK later without rewriting business logic.
MCP Server for AI Tools
If your client is an AI assistant rather than application code, use the official MCP server instead of writing a wrapper. africa-api-mcp runs with npx -y africa-api-mcp and exposes 41 read-only tools to Claude, Cursor, and any MCP-compatible client. See the MCP server guide for setup.
Client Patterns
const BASE_URL = "https://api.africa-api.com";
async function africaRequest<T>(path: string): Promise<T> {
const response = await fetch(`${BASE_URL}${path}`, {
headers: {
Authorization: `Bearer ${process.env.AFRICA_API_KEY ?? ""}`,
},
});
if (!response.ok) {
throw new Error(`Africa API request failed: ${response.status}`);
}
return response.json() as Promise<T>;
}
export function listIndicators(category?: string) {
const suffix = category ? `?category=${encodeURIComponent(category)}` : "";
return africaRequest<{ data: Array<{ key: string; name: string }> }>(
`/v1/indicators${suffix}`,
);
}
export function listData(countryCode: string, metricKey: string) {
return africaRequest(`/v1/data?country_code=${countryCode}&metric_key=${metricKey}&latest=true`);
}import requests
BASE_URL = "https://api.africa-api.com"
def africa_request(path: str, api_key: str) -> dict:
response = requests.get(
f"{BASE_URL}{path}",
headers={"Authorization": f"Bearer {api_key}"},
timeout=10,
)
response.raise_for_status()
return response.json()
def list_indicators(api_key: str, category: str | None = None) -> dict:
suffix = f"?category={category}" if category else ""
return africa_request(f"/v1/indicators{suffix}", api_key)
def list_data(api_key: str, country_code: str, metric_key: str) -> dict:
return africa_request(
f"/v1/data?country_code={country_code}&metric_key={metric_key}&latest=true",
api_key,
)OpenAPI Schema
If you prefer generated clients:
https://api.africa-api.com/openapi.jsonPin generated clients to the /v1 routes you actually use.