Afriex SDK
API Reference

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); // Unix timestamp

You can omit either filter to broaden the response, or omit both to fetch all available rate pairs:

const allRates = await afriex.rates.getRates();

Parameters:

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

Both fields are optional. If omitted, the API returns all matching base or target currencies.

Get Single Rate

const rate = await afriex.rates.getRate("USD", "NGN");

console.log("USD to NGN:", rate); // "1550.00"

Convert Amount

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
}

On this page