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
- Always send the
Authorizationheader from day one. - Store credentials server-side in production workloads.
- Keep separate keys per environment (
dev,staging,prod). - 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 Unauthorized403 Forbidden
See Errors for handling patterns.