Skip to main content
POST /offramp/rate endpoint returns the current exchange rate for converting a supported stablecoin to a local currency. Call this endpoint before creating an actual payment transaction to show users exactly how much they’ll receive.

Example Request

curl -L \
  --request POST \
  --url 'https://api.onswitch.xyz/offramp/rate' \
  --header 'x-service-key: '"$YOUR_SERVICE_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "asset": "base:usdc",
    "country": "NG",
    "currency": "NGN"
  }'
const res = await fetch('https://api.onswitch.xyz/offramp/rate', {
  method: 'POST',
  headers: {
    'x-service-key': process.env.YOUR_SERVICE_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    asset: 'base:usdc',
    country: 'NG',
    currency: 'NGN',
  }),
});

const { rate } = await res.json();
console.log(`1 USDC = ${rate} NGN`);
import os, json, urllib.request

payload = {
    "asset": "base:usdc",
    "country": "NG",
    "currency": "NGN",
}

req = urllib.request.Request(
    "https://api.onswitch.xyz/offramp/rate",
    data=json.dumps(payload).encode(),
    method="POST",
    headers={
        "x-service-key": os.environ["YOUR_SERVICE_KEY"],
        "Content-Type": "application/json",
    },
)

with urllib.request.urlopen(req, timeout=30) as r:
    data = json.load(r)
    print(f"1 USDC = {data['rate']} NGN")

Example Response

{
  "success": true,
  "message": "Offramp rate fetched successfully",
  "timestamp": "2024-01-01T00:00:00.000Z",
  "data": {
    "currency": "NGN",
    "channel": "BANK",
    "rate": 1408.761
  }
}
Rates reflect current market conditions and may change between the time you fetch them and when a transaction is submitted. Always re-fetch the rate immediately before creating a transaction.

Need Help?

Email Support

Send us a message.

Book a call

Hop on a call with us.