Latest Rates

Get the latest exchange rate between any two supported currencies.

GET https://afrotools.com/api/forex
Authentication required. Pass your API key via x-api-key header. Learn more

Request Parameters

ParameterTypeDescription
from required string Source currency code (e.g., USD, EUR, GBP, BTC).
to required string Target currency code (e.g., NGN, KES, ZAR).
amount optional number Amount to convert. Default: 1.
date optional string Historical date in YYYY-MM-DD format. Omit for latest. Pro plan required.

Response Fields

FieldTypeDescription
fromstringSource currency code.
tostringTarget currency code.
ratenumberMid-market exchange rate.
bidnumberBid price (buy rate).
asknumberAsk price (sell rate).
amountnumberConverted amount (if amount param was provided).
change_24hnumberAbsolute change in last 24 hours.
change_pct_24hnumberPercentage change in last 24 hours.
timestampstringISO 8601 timestamp of the rate.
sourcestringData source (e.g., CBN, SARB, CBK).

Error Responses

StatusCodeDescription
400invalid_currencyOne or both currency codes are not supported.
400invalid_dateDate format is invalid or date is in the future.
401missing_api_keyNo API key was provided.
403plan_requiredHistorical data requires Pro plan or above.
429rate_limit_exceededRate limit exceeded.
Request Examples
curl "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(`1 USD = ${data.data.rate} NGN`);
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(f"1 USD = {data['data']['rate']} NGN")
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(`1 USD = ${data.data.rate} NGN`);
$ch = curl_init( "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); echo "1 USD = " . $data["data"]["rate"] . " NGN";

Response (200 OK)
{ "success": true, "data": { "from": "USD", "to": "NGN", "rate": 1580.25, "bid": 1578.50, "ask": 1582.00, "change_24h": -0.35, "change_pct_24h": -0.022, "timestamp": "2026-03-15T10:30:00Z", "source": "CBN" } }

With Amount Conversion
# Convert 1000 USD to NGN curl "https://afrotools.com/api/forex?from=USD&to=NGN&amount=1000" \ -H "x-api-key: afro_test_abc123"
{ "success": true, "data": { "from": "USD", "to": "NGN", "rate": 1580.25, "amount": 1580250.00, "bid": 1578500.00, "ask": 1582000.00, "timestamp": "2026-03-15T10:30:00Z", "source": "CBN" } }