HomeConverter

API Documentation

Use this documentation to connect to the Citrusrate API and WebSocket streams.

Citrusrate V1 API Documentation

Welcome to the Citrusrate V1 API. This API provides real-time and black-market exchange rates for Bitcoin (BTC) and Fiat currencies across Africa.

Base URL

https://api.citrusrate.com/v1

Authentication

All requests to the V1 API must use an API key. Put your API key in the X-API-Key header of every request.

To get an API key, buy a developer plan. View the plans on the Developer Plans page.

Example Request:

curl -H "X-API-Key: your_api_key_here" \
  "https://api.citrusrate.com/v1/btc?currency=NGN"
⚠️ IMPORTANT: Keep your API key secret. Do not share your key in public repositories or client-side code.

Supported Currencies (African Fiat)

Citrusrate currently supports 41 African currencies. Use these tickers in the currency query parameter for any endpoint.

TickerCurrency NameTickerCurrency Name
AOAAngolan KwanzaMADMoroccan Dirham
BIFBurundian FrancMGAMalagasy Ariary
BWPBotswana PulaMROMauritanian Ouguiya
CVECape Verdean EscudoMURMauritian Rupee
CDFCongolese FrancMWKMalawian Kwacha
DJFDjiboutian FrancMZNMozambican Metical
DZDAlgerian DinarNADNamibian Dollar
ERNEritrean NakfaNGNNigerian Naira
ETBEthiopian BirrRWFRwandan Franc
GHSGhanaian CediSCRSeychellois Rupee
GMDGambian DalasiGNFGuinean Franc
KESKenyan ShillingLRDLiberian Dollar
KMFComorian FrancLSLLesotho Loti
LYDLibyan DinarSDGSudanese Pound
SLLSierra Leonean LeoneSOSSomali Shilling
SSPSouth Sudanese PoundSTNSão Tomé Dobra
SZLEswatini LilangeniTNDTunisian Dinar
TZSTanzanian ShillingUGXUgandan Shilling
XAFCentral African CFA FrancXOFWest African CFA Franc
ZARSouth African RandZMWZambian Kwacha
ZWDZimbabwean Dollar

Supported Black Market Currencies

We provide parallel market and peer-to-peer (P2P) rate data for these 13 currencies:

TickerCurrency NameTickerCurrency Name
EGPEgyptian PoundETBEthiopian Birr
GHSGhanaian CediMWKMalawian Kwacha
MZNMozambican MeticalNADNamibian Dollar
RWFRwandan FrancTZSTanzanian Shilling
UGXUgandan ShillingXAFCentral African CFA Franc
XOFWest African CFA FrancZARSouth African Rand
ZMWZambian Kwacha

L402 Lightning Auth

If you do not have an API key, you can use the L402 protocol. If you send a request without a key, the server returns an HTTP 402 error. This error contains a Lightning invoice.

Pay the invoice with a Lightning wallet to get a Macaroon token. This token grants you 10 minutes of access to the endpoint. Put this token in the Authorization header to complete your requests. Standard API rate limits apply during this 10-minute window.

This is an example of the HTTP 402 (Payment Required) response:

{
  "status": "payment_required",
  "message": "Payment of 500 sats required to access this endpoint.",
  "payment": {
    "macaroon": "ASI2yzTmASi5b5...",
    "invoice": "lnbc500n1p4xp5y9p...",
    "paymentHash": "2236cb34e6...",
    "amount": 500,
    "currency": "SAT",
    "expiresAt": "2026-07-22T14:27:05.000Z"
  },
  "service": {
    "name": "Citrusrate",
    "description": "Real-time FX rates for African currencies",
    "endpoint": "/v1/fiat/mid?currency=MWK"
  }
}

WebSocket Streaming

Citrusrate sends real-time data with Socket.IO for premium plans. Use a standard Socket.IO client to connect. Put your API key in the auth object.

1. Real-Time Prices Stream

This stream sends all official African exchange rates every 3 seconds. Namespace: /ws/developer/prices

import { io } from "socket.io-client";

const socket = io("wss://api.citrusrate.com/ws/developer/prices", {
  auth: { apiKey: "your_api_key_here" }
});

socket.on("connect", () => console.log("Connected!"));
socket.on("data", (prices) => {
  console.log("Live Prices:", prices);
});

2. Black Market Rates Stream

This stream sends live peer-to-peer (P2P) and parallel market data every 5 seconds. Namespace: /ws/developer/blackmarket

import { io } from "socket.io-client";

const socket = io("wss://api.citrusrate.com/ws/developer/blackmarket", {
  auth: {
    apiKey: "your_api_key_here",
    currencies: ["NGN", "GHS", "KES"] // Max Tier only
  }
});

socket.on("data", (rates) => {
  console.log("Black Market Rates:", rates);
});

Business plan: You do not need to send the currencies list to get all rates.

Best Practices

  • Caching: Cache the rate data on your side for at least 30 to 60 seconds to get better performance.
  • Handling 429s: If you receive an HTTP 429 error, read the retryAfter field (in seconds) before you send a new request.
  • Timeouts: Make sure that your client handles network timeouts correctly. We recommend a timeout of 5 to 10 seconds.

Error Codes

The API uses standard HTTP status codes to show if a request is successful or has an error. These are the common error codes:

CodeMeaningDescription
400Bad RequestMissing or invalid parameters.
401UnauthorizedAPI key is missing, invalid, or revoked.
403ForbiddenYour API key does not have the required scope.
429Too Many RequestsYou have exceeded your rate limit.
500Server ErrorInternal issue; please contact support.
GEThttps://api.citrusrate.com/v1/btc

Get Official Single Price

Get the current Bitcoin (BTC) exchange rate against a specific fiat currency.

Parameters

NameTypeDescription
currency*stringThe currency ticker (e.g. NGN).
curl -X GET "https://api.citrusrate.com/v1/btc?currency=NGN" \ -H "X-API-Key: YOUR_API_KEY"
Example Response

Headers

NameTypeDescription
X-API-KeystringYour Citrusrate API key used to authorize the request.

Response Fields

FieldTypeDescription
statusstringOverall result of the request, e.g. success.
data.pairstringCurrency pair quoted, here BTC/NGN.
data.ratenumberCurrent exchange rate for 1 BTC in NGN.
data.timestampstring (ISO 8601)Time the rate was generated.
GEThttps://api.citrusrate.com/v1/btc/batch

Get Official Batch Price

Returns the current BTC exchange rates in up to five multiple African fiat currencies.

Parameters

NameTypeDescription
currencies*stringComma-separated list of fiat currency codes (max 5), e.g. NGN,GHS,XOF,ZAR,KES
curl -X GET "https://api.citrusrate.com/v1/btc/batch?currencies=NGN,GHS,XOF,ZAR,KES" \ -H "X-API-Key: YOUR_API_KEY"
Example Response

Headers

NameTypeDescription
X-API-KeystringYour Citrusrate API key used to authorize the request.

Response Fields

FieldTypeDescription
statusstringHigh-level status of the request (e.g. success).
dataobjectMap of currency code to rate information.
data.<CURRENCY>objectKey for each requested fiat currency (e.g. NGN, GHS, XOF, ZAR, KES).
data.<CURRENCY>.ratenumberCurrent BTC price denominated in that fiat currency.
data.<CURRENCY>.timestampstring (ISO 8601)ISO-8601 timestamp indicating when the rate was last updated.
GEThttps://api.citrusrate.com/v1/btc/all

BTC All Fiat Rates

Retrieve the latest BTC conversion rates against all supported fiat currencies.

curl -X GET "https://api.citrusrate.com/v1/btc/all" \ -H "X-API-Key: YOUR_API_KEY"
Example Response

Headers

NameTypeDescription
X-API-KeystringYour Citrusrate API key used to authorize the request.

Response Fields

FieldTypeDescription
statusstringString flag indicating request outcome (e.g. success).
dataobjectObject wrapping the payload.
data.ratesobjectObject where each key is a 3-letter fiat currency code and the value is the rate of 1 BTC in that currency.
data.timestampstring (ISO 8601)ISO-8601 timestamp string indicating when the rates snapshot was generated.
GEThttps://api.citrusrate.com/v1/btc/blackmarket

Get Black Market Single Rate

Retrieve the current black-market Bitcoin (BTC) exchange rate for a specific fiat currency.

Parameters

NameTypeDescription
currency*stringISO currency code of the fiat currency, e.g. MZN
curl -X GET "https://api.citrusrate.com/v1/btc/blackmarket?currency=MZN" \ -H "X-API-Key: YOUR_API_KEY"
Example Response

Headers

NameTypeDescription
X-API-KeystringYour Citrusrate API key used to authorize the request.
Content-TypestringMust be set to application/json

Response Fields

FieldTypeDescription
statusstringHigh-level status of the request (e.g., success).
data.pairstringCurrency pair quoted, here BTC/MZN.
data.ratenumberCurrent estimated BTC price denominated in Mozambican Metical (MZN).
data.timestampstring (ISO 8601)ISO-8601 timestamp indicating when the rate was last updated.
data.sourcestringRate generation methodology (e.g. live).
GEThttps://api.citrusrate.com/v1/btc/blackmarket/all

Get Black Market All Rates

Retrieve the current black-market Bitcoin (BTC) exchange rate for all supported currencies.

curl -X GET "https://api.citrusrate.com/v1/btc/blackmarket/all" \ -H "X-API-Key: YOUR_API_KEY"
Example Response

Headers

NameTypeDescription
X-API-KeystringYour Citrusrate API key used to authorize the request.
Content-TypestringMust be set to application/json

Response Fields

FieldTypeDescription
statusstringHigh-level status of the request (e.g. success).
data.ratesobjectMap of currency codes to rate objects.
data.rates.<CURRENCY>.ratenumberBlack-market exchange rate of BTC in that currency.
data.timestampstring (ISO 8601)ISO-8601 timestamp string indicating when the snapshot was generated.