Skip to Content
APIRates

Rates API

Get exchange rates between currencies.

Get Rates

const response = await afriex.rates.getRates({ base: 'USD,NGN', symbols: '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
basestring | string[]Base currencies (comma-separated or array)
symbolsstring | 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: { [baseCurrency: string]: { [targetCurrency: string]: string } }, base: string[], updatedAt: number // Unix timestamp }
Last updated on