Skip to Content
APIRates

Rates API

Get exchange rates between currencies.

Get Rates

const response = await afriex.rates.getRates({ fromSymbols: "USD,NGN", toSymbols: "NGN,USD,GBP,KES", }); console.log(response.rates); // { // USD: { NGN: '1550.00', GBP: '0.79', KES: '129.50' }, // NGN: { USD: '0.00065', GBP: '0.00051', KES: '0.0835' } // } console.log(response.updatedAt); // Timestamp

Parameters:

FieldTypeDescription
fromSymbolsstring | string[]Base currencies (comma-separated or array)
toSymbolsstring | string[]Target currencies to get rates for

Get Single Rate

Get the exchange rate between two specific currencies:

const rate = await afriex.rates.getRate("USD", "NGN"); console.log("USD to NGN:", rate); // "1550.00"

Convert Amount

Convert an amount from one currency to another:

const result = await afriex.rates.convert(100, "USD", "NGN"); console.log("100 USD in NGN:", result); // 155000

Response Format

{ rates: { [fromSymbol: string]: { [toSymbol: string]: string } }, updatedAt: number // Unix timestamp }