Africa API

Authentication

Authentication model and forward-compatible implementation guidance.

Platform Auth Model

Africa API uses bearer-token authentication for API access.

During platform rollout phases, selected read endpoints may operate in open beta mode while the token model is standardized across domains.

Request Format

curl "https://api.africa-api.com/v1/countries" \
  -H "Authorization: Bearer YOUR_API_KEY"

Implementation Guidance

  1. Always send the Authorization header from day one.
  2. Store credentials server-side in production workloads.
  3. Keep separate keys per environment (dev, staging, prod).
  4. Rotate keys on any suspected exposure.

JavaScript Pattern

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

Expected Auth Error Modes

When auth is enforced on an endpoint, handle:

  • 401 Unauthorized
  • 403 Forbidden

See Errors for handling patterns.

On this page