Authentication

Authenticate your API requests using an API key passed via header or query parameter.

API Keys

Every request to the AfroTools API must include a valid API key. You can obtain a key by signing up for a free account on afrotools.com.

Key Formats

PrefixEnvironmentDescription
afro_live_ProductionUse in production applications. Requests count against your plan quota.
afro_test_SandboxUse during development. Returns sample data. Does not count against quota.

Passing Your Key

You can authenticate using either method. The header approach is recommended for production use.

Option 1: HTTP Header (Recommended)

Pass your API key in the x-api-key request header.

Option 2: Query Parameter

Append api_key as a query parameter to any endpoint URL. This method is useful for quick testing but is less secure since the key may appear in server logs and browser history.

Security note: Never expose your API key in client-side JavaScript on public websites. Use a backend proxy to keep your key secret.

Authentication Errors

StatusErrorDescription
401missing_api_keyNo API key was provided in the request.
401invalid_api_keyThe API key is malformed or does not exist.
403key_disabledThe API key has been disabled. Contact support.
429rate_limit_exceededYou have exceeded your plan's rate limit.
Header Authentication
curl -X GET "https://afrotools.com/api/forex?from=USD&to=NGN" \ -H "x-api-key: afro_live_your_key_here"
const res = await fetch( "https://afrotools.com/api/forex?from=USD&to=NGN", { headers: { "x-api-key": "afro_live_your_key_here" } } ); const data = await res.json(); console.log(data);
import requests resp = requests.get( "https://afrotools.com/api/forex", params={"from": "USD", "to": "NGN"}, headers={"x-api-key": "afro_live_your_key_here"} ) data = resp.json() print(data)
const axios = require("axios"); const { data } = await axios.get( "https://afrotools.com/api/forex", { params: { from: "USD", to: "NGN" }, headers: { "x-api-key": "afro_live_your_key_here" } } ); console.log(data);
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://afrotools.com/api/forex?from=USD&to=NGN"); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "x-api-key: afro_live_your_key_here" ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); print_r($data);

Query Parameter Authentication
curl "https://afrotools.com/api/forex?from=USD&to=NGN&api_key=afro_live_your_key_here"

Error Response (401)
{ "success": false, "error": { "code": "missing_api_key", "message": "No API key provided. Include x-api-key header or api_key query parameter.", "docs": "https://afrotools.com/docs/api/authentication.html" } }