GetExchangeRate returns the exchange rate from USD to a specified currency.
curl --request POST \
--url https://api.example.com/rpc/Trails/GetExchangeRate \
--header 'Content-Type: application/json' \
--data '
{
"toCurrency": "<string>"
}
'import requests
url = "https://api.example.com/rpc/Trails/GetExchangeRate"
payload = { "toCurrency": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({toCurrency: '<string>'})
};
fetch('https://api.example.com/rpc/Trails/GetExchangeRate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/rpc/Trails/GetExchangeRate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'toCurrency' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/rpc/Trails/GetExchangeRate"
payload := strings.NewReader("{\n \"toCurrency\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/rpc/Trails/GetExchangeRate")
.header("Content-Type", "application/json")
.body("{\n \"toCurrency\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/rpc/Trails/GetExchangeRate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"toCurrency\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"exchangeRate": {
"name": "<string>",
"symbol": "<string>",
"value": 123,
"vsCurrency": "<string>",
"currencyType": "<string>"
}
}{
"error": "WebrpcEndpoint",
"code": 0,
"msg": "endpoint error",
"status": 400,
"cause": "<string>"
}{
"error": "WebrpcBadResponse",
"code": -5,
"msg": "bad response",
"status": 500,
"cause": "<string>"
}Chains & Discovery
GetExchangeRate
POST
/
rpc
/
Trails
/
GetExchangeRate
GetExchangeRate returns the exchange rate from USD to a specified currency.
curl --request POST \
--url https://api.example.com/rpc/Trails/GetExchangeRate \
--header 'Content-Type: application/json' \
--data '
{
"toCurrency": "<string>"
}
'import requests
url = "https://api.example.com/rpc/Trails/GetExchangeRate"
payload = { "toCurrency": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({toCurrency: '<string>'})
};
fetch('https://api.example.com/rpc/Trails/GetExchangeRate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/rpc/Trails/GetExchangeRate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'toCurrency' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/rpc/Trails/GetExchangeRate"
payload := strings.NewReader("{\n \"toCurrency\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/rpc/Trails/GetExchangeRate")
.header("Content-Type", "application/json")
.body("{\n \"toCurrency\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/rpc/Trails/GetExchangeRate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"toCurrency\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"exchangeRate": {
"name": "<string>",
"symbol": "<string>",
"value": 123,
"vsCurrency": "<string>",
"currencyType": "<string>"
}
}{
"error": "WebrpcEndpoint",
"code": 0,
"msg": "endpoint error",
"status": 400,
"cause": "<string>"
}{
"error": "WebrpcBadResponse",
"code": -5,
"msg": "bad response",
"status": 500,
"cause": "<string>"
}Overview
TheGetExchangeRate 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
Was this page helpful?