africaAPI

Platform

SDKs

Current SDK status and recommended client patterns.

Official SDK packages are not yet published. Use direct HTTP clients with small internal wrappers so you can migrate to official SDKs later without refactoring your app logic.

Client Patterns

type CountriesResponse = {
  data: Array<{ id: string; name: string; region: string }>;
  meta: { total: number; page: number; per_page: number; total_pages: number };
};

export async function listCountries(): Promise<CountriesResponse> {
  const response = await fetch("https://api.africa-api.com/v1/countries", {
    headers: {
      Authorization: `Bearer ${process.env.AFRICA_API_KEY ?? ""}`,
    },
  });

  if (!response.ok) throw new Error(`Request failed: ${response.status}`);
  return response.json();
}
import requests

BASE_URL = "https://api.africa-api.com"


def list_countries(api_key: str | None = None) -> dict:
    headers = {}
    if api_key:
        headers["Authorization"] = f"Bearer {api_key}"

    response = requests.get(f"{BASE_URL}/v1/countries", headers=headers, timeout=10)
    response.raise_for_status()
    return response.json()

Generate Clients from OpenAPI

If you prefer generated clients, use the OpenAPI schema:

https://api.africa-api.com/openapi.json

Pin generated clients to a specific API version path (/v1) for stability.

On this page