API Reference

RESTful API for accessing AFXO FX rates, confidence scores, and historical data. All endpoints require authentication via API key.

Quick Start

All API requests require an API key passed in the X-API-Key header.

curl -X GET "https://api.afxo.ai/v1/rates/KES/USD" \
  -H "X-API-Key: your_api_key_here"

Base URL

https://api.afxo.ai

Authentication

Include your API key in every request header:

X-API-Key: your_api_key

Get your API key from the API Access page.

Endpoints

GET/v1/rates/{base}/{quote}

Get current exchange rate for a currency pair

Example: /v1/rates/KES/USD
GET/v1/rates/{base}/{quote}/history

Get historical rates with optional date range

Example: /v1/rates/KES/USD/history?from=2026-01-01&to=2026-01-15
GET/v1/currencies

List all supported currencies

Example: /v1/currencies
GET/v1/currencies/{code}

Get details for a specific currency

Example: /v1/currencies/KES
GET/v1/confidence/{base}/{quote}

Get confidence score and quality metrics

Example: /v1/confidence/KES/USD

Response Format

All responses are returned in JSON format:

{
  "success": true,
  "data": {
    "base": "KES",
    "quote": "USD",
    "rate": 0.00775,
    "inverse": 129.032,
    "confidence": 94,
    "sources": 5,
    "timestamp": "2026-01-19T10:30:00Z",
    "updated_at": "2026-01-19T10:30:00Z"
  },
  "meta": {
    "request_id": "req_abc123",
    "latency_ms": 42
  }
}

Confidence Scores

Each rate includes a confidence score (0-100) reflecting overall data reliability and quality:

85-100
High Confidence
Multiple sources in strong agreement. Suitable for high-stakes applications.
70-84
Medium Confidence
Acceptable agreement with minor discrepancies. May warrant additional verification.
50-69
Low Confidence
Source disagreement or quality concerns. Use with caution.
<50
Critical
Significant issues. Updates halted until quality improves.

Note: On-chain oracles enforce a minimum confidence threshold (default: 70%). Updates below this threshold are rejected to protect downstream applications.

Rate Limits

Rate limits are designed to accommodate each plan's update frequency with buffer for weekends and high-activity periods.

PlanUpdate FrequencyRequests/minRequests/day
SandboxDaily (1x)5100
StarterHourly (24x)301,000
Builder5-minute (288x)6010,000
Growth1-minute (1,440x)300100,000
EnterpriseSub-minuteCustomUnlimited

Daily limits apply across all 7 days including weekends. Exceeding rate limits returns a 429 status code.

Error Codes

CodeDescription
400Bad Request — Invalid parameters
401Unauthorized — Invalid or missing API key
403Forbidden — Insufficient permissions for this resource
404Not Found — Currency pair not supported
429Too Many Requests — Rate limit exceeded
500Internal Server Error — Please retry or contact support

SDKs & Libraries

Official client libraries are available for popular languages:

JavaScript / TypeScript
npm install @afxo/sdk
Python
pip install afxo

See SDK Documentation for detailed usage.