AfriRate — Pan-African Exchange Rates
API reference

AfriRate API

One REST endpoint per dataset. JSON in, JSON out. Same shape across all 28 countries. Free tier is 10 req/min, 300 req/day — enough for most apps without billing.

Authentication

Every /api/v1/* endpoint requires a key. Create one on the dashboard after signing in. Pass it either way:

Authorization: Bearer ar_xxxxxxxxxxxxxxxxxxxxxxxx

# or as a query param
?api_key=ar_xxxxxxxxxxxxxxxxxxxxxxxx

Header form is preferred — query params leak into logs and browser history.

Base URL

https://afrirate.statotec.com/api/v1/

All endpoints below are relative to this base. HTTPS only.

Errors

Errors use a consistent envelope.

{
  "error": {
    "code": "rate_limited",
    "message": "Daily request limit (300) reached. Upgrade or wait until UTC midnight.",
    "status": 429
  },
  "meta": { "timestamp": "2026-05-17T10:00:00Z" }
}
StatusCodeMeaning
400bad_requestMissing or invalid parameter.
401unauthorizedMissing or invalid API key.
403forbiddenKey revoked or account disabled.
404not_foundNo data for the requested filter (e.g. inflation for a country whose source doesn't publish it).
429rate_limitedDaily or per-minute limit hit.
500internalSomething went wrong on our side. Retry; if persistent, file an issue.

Rate limits

Free tier: 10 requests / minute, 300 / day. Premium plans raise both — see pricing.

Every response carries:

X-RateLimit-Limit:        10
X-RateLimit-Remaining:    7
X-RateLimit-Reset:        1779000420
X-Daily-Limit:           300
X-Daily-Remaining:       293

Webhooks

On the Starter plan and above, AfriRate can POST to your server whenever a central bank publishes new rates, instead of you polling. Add a webhook under Dashboard → Webhooks: an https URL, and optionally the countries you want. You get a signing secret once; keep it.

Each delivery is one country, one source and one day. The event is rates.updated, or ping when you press Send test.

POST https://your-server.example/afrirate
Content-Type:       application/json
AfriRate-Event:     rates.updated
AfriRate-Delivery:  1842
AfriRate-Signature: t=1792630800,v1=5f2c…

{
  "id": "1842",
  "event": "rates.updated",
  "country": "ZW",
  "source": "rbz",
  "rate_date": "2026-10-21",
  "rates": [
    { "base": "USD", "quote": "ZWG", "rate": "26.5975", "bid": null, "ask": null, "rate_date": "2026-10-21" }
  ],
  "sent_at": "2026-10-21T08:02:11.000Z"
}

Check the signature before trusting a delivery: compute HMAC-SHA256 of `${t}.${raw body}` with your secret and compare it with v1. Reject deliveries whose t is more than five minutes old.

// Node.js (Express: use express.raw() so you sign the exact bytes received)
import { createHmac, timingSafeEqual } from 'node:crypto';

function verify(rawBody, header, secret) {
  const { t, v1 } = Object.fromEntries(header.split(',').map((p) => p.split('=')));
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
  const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
  return timingSafeEqual(Buffer.from(expected), Buffer.from(v1));
}
# Python
import hmac, hashlib, time

def verify(raw_body: bytes, header: str, secret: str) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    if abs(time.time() - int(parts["t"])) > 300:
        return False
    expected = hmac.new(secret.encode(), f"{parts['t']}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts["v1"])

Answer with any 2xx within 10 seconds. Anything else, including a redirect, counts as a failure and is retried after 1, 5, 30, 120 and 360 minutes. A delivery can arrive more than once, so use id to skip duplicates. After 50 failures in a row the webhook is switched off; turn it back on in the dashboard. Every attempt shows under Recent deliveries.

GET/api/v1/rates/latest

Latest exchange rates, filterable by country and/or pair. Each rate carries a `stale` flag — true when its source has been unreachable recently, so the value is the last we published rather than a fresh refresh.

ParameterRequiredDescription
countryoptionalISO 3166-1 alpha-2 country code. · e.g. ZW
baseoptionalISO 4217 base currency code. · e.g. USD
quoteoptionalISO 4217 quote currency code. · e.g. ZWG
Example request
curl "https://afrirate.statotec.com/api/v1/rates/latest?country=ZW&base=USD&quote=ZWG" \
  -H "Authorization: Bearer ar_xxx..."
Example response
{
  "data": [
    {
      "source": "rbz",
      "country": "ZW",
      "base": "USD",
      "quote": "ZWG",
      "rate": "25.8135",
      "bid":  "25.1682",
      "ask":  "26.4588",
      "rate_date":  "2026-05-15",
      "updated_at": "2026-05-15T08:14:22Z",
      "stale": false
    }
  ],
  "meta": { "timestamp": "2026-05-17T10:00:00Z", "count": 1 }
}
GET/api/v1/rates/history

Daily rates over a date range: one rate per source, pair and day. How far back you can read depends on your plan: Free 30 days, Starter 90, Pro and Business 365. A `from` earlier than that is moved forward and `limited_by_plan` is true. Without `from`, you get the last 30 days.

ParameterRequiredDescription
countryoptionalISO 3166-1 alpha-2 country code. Or give base and quote. · e.g. ZW
baseoptionalISO 4217 base currency code. · e.g. USD
quoteoptionalISO 4217 quote currency code. · e.g. ZWG
fromoptionalFirst day, YYYY-MM-DD. · e.g. 2026-10-01
tooptionalLast day, YYYY-MM-DD. Defaults to today. · e.g. 2026-10-21
Example request
curl "https://afrirate.statotec.com/api/v1/rates/history?country=ZW&base=USD&quote=ZWG&from=2026-10-01&to=2026-10-21" \
  -H "Authorization: Bearer ar_xxx..."
Example response
{
  "data": {
    "country": "ZW",
    "from": "2026-10-01",
    "to": "2026-10-21",
    "history_days": 30,
    "earliest_allowed": "2026-09-21",
    "limited_by_plan": false,
    "rates": [
      { "source": "rbz", "base": "USD", "quote": "ZWG", "rate": "26.6124",
        "bid": null, "ask": null, "rate_date": "2026-10-20" }
    ]
  },
  "meta": { "timestamp": "2026-10-21T10:00:00Z", "count": 1 }
}
GET/api/v1/inflation/latest

Latest inflation figures for a country. Only countries whose central bank publishes inflation will return rows.

ParameterRequiredDescription
countryrequiredISO 3166-1 alpha-2 country code. · e.g. ZW
Example request
curl "https://afrirate.statotec.com/api/v1/inflation/latest?country=ZW" \
  -H "Authorization: Bearer ar_xxx..."
Example response
{
  "data": [
    {
      "source": "rbz",
      "country": "ZW",
      "denomination": "USD",
      "period_date": "2026-04-01",
      "mom": "1.06",
      "yoy": "2.16",
      "cpi_index": "124.76"
    }
  ],
  "meta": { "timestamp": "2026-05-17T10:00:00Z", "count": 1 }
}
GET/api/v1/gold/latest

Latest central-bank gold-coin prices. Currently only RBZ (Zimbabwe).

ParameterRequiredDescription
countryrequiredISO 3166-1 alpha-2 country code. · e.g. ZW
Example request
curl "https://afrirate.statotec.com/api/v1/gold/latest?country=ZW" \
  -H "Authorization: Bearer ar_xxx..."
Example response
{
  "data": [
    {
      "source": "rbz",
      "country": "ZW",
      "product": "mosi_oa_tunya",
      "priced_in": "USD",
      "selling_price": "4805.64",
      "prev_pm_fix":  "4576.80",
      "price_date":   "2026-04-06"
    }
  ],
  "meta": { "timestamp": "2026-05-17T10:00:00Z", "count": 1 }
}
GET/api/v1/countries

List every country AfriRate covers, with its local currency and slug.

Example request
curl "https://afrirate.statotec.com/api/v1/countries" \
  -H "Authorization: Bearer ar_xxx..."
Example response
{
  "data": [
    { "code": "ZW", "slug": "zimbabwe",     "name": "Zimbabwe",     "currency": "ZWG" },
    { "code": "ZA", "slug": "south-africa", "name": "South Africa", "currency": "ZAR" },
    ...
  ],
  "meta": { "timestamp": "2026-05-17T10:00:00Z", "count": 28 }
}
GET/api/v1/currencies

List every currency AfriRate publishes rates for, with name, symbol, and decimal precision. Public, no key required.

Example request
curl "https://afrirate.statotec.com/api/v1/currencies" \
  -H "Authorization: Bearer ar_xxx..."
Example response
{
  "data": [
    { "code": "USD", "name": "United States Dollar", "symbol": "$",   "decimals": 2 },
    { "code": "ZWG", "name": "Zimbabwe Gold",         "symbol": "ZiG", "decimals": 2 },
    ...
  ],
  "meta": { "timestamp": "2026-05-17T10:00:00Z", "count": 24 }
}
GET/api/v1/health

Service health probe. Public, no key required. Returns 200 with the current update health of each source.

Example request
curl "https://afrirate.statotec.com/api/v1/health" \
  -H "Authorization: Bearer ar_xxx..."
Example response
{
  "status": "ok",
  "sources": [
    { "code": "sarb", "country": "ZA", "last_success_at": "2026-05-17T18:00:11Z", "consecutive_failures": 0 },
    ...
  ]
}