Skip to main content
POST
/
rpc
/
Trails
/
GetExchangeRate
GetExchangeRate returns the exchange rate from USD to a specified currency.
curl --request POST \
  --url https://trails-api.sequence.app/rpc/Trails/GetExchangeRate \
  --header 'Content-Type: application/json' \
  --data '
{
  "toCurrency": "<string>"
}
'
{
  "exchangeRate": {
    "name": "<string>",
    "symbol": "<string>",
    "value": 123,
    "vsCurrency": "<string>",
    "currencyType": "<string>"
  }
}

Overview

The GetExchangeRate endpoint returns the current exchange rate for a fiat currency against USD. Use this to display fiat-denominated amounts in your UI or to convert token values to a user’s local currency.

Use Cases

  • Display token prices in local fiat currencies
  • Power fiat input mode in fund/withdraw flows
  • Build currency selectors with live exchange rates
  • Show USD-equivalent values in non-USD currencies

Request Parameters

Optional Fields

  • toCurrency (string): ISO 4217 currency code (e.g. "EUR", "GBP", "JPY"). Defaults to "USD" if omitted.

Response

  • exchangeRate (ExchangeRate): Exchange rate object

ExchangeRate Object Structure

  • name (string): Full name of the currency (e.g. "Euro")
  • symbol (string): Currency symbol (e.g. "€")
  • value (number): Exchange rate value relative to vsCurrency
  • vsCurrency (string): The base currency (typically "USD")
  • currencyType (string): Currency type identifier

Examples

Get EUR Exchange Rate

const response = await fetch('https://trails-api.sequence.app/rpc/Trails/GetExchangeRate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Access-Key': 'YOUR_ACCESS_KEY'
  },
  body: JSON.stringify({ toCurrency: 'EUR' })
});

const { exchangeRate } = await response.json();

console.log(`1 USD = ${exchangeRate.value} ${exchangeRate.symbol}`);
// e.g. "1 USD = 0.92 €"

Convert a USD Amount

async function convertToLocal(usdAmount: number, currency: string): Promise<string> {
  const response = await fetch('https://trails-api.sequence.app/rpc/Trails/GetExchangeRate', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Access-Key': 'YOUR_ACCESS_KEY'
    },
    body: JSON.stringify({ toCurrency: currency })
  });

  const { exchangeRate } = await response.json();
  const localAmount = usdAmount * exchangeRate.value;

  return `${exchangeRate.symbol}${localAmount.toFixed(2)}`;
}

const display = await convertToLocal(100, 'GBP');
console.log(display); // "£82.50"
Use GetFiatCurrencyList to retrieve the full list of supported currencies and their codes before calling this endpoint.

Next Steps

GetFiatCurrencyList

Get the list of supported fiat currencies

GetTokenPrices

Get USD prices for on-chain tokens

Body

application/json
toCurrency
string

Response

OK

exchangeRate
object