> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onswitch.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Get rate

> Fetch rate for stablecoin to local currency conversion.

**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

<CodeGroup>
  ```bash cURL theme={"dark"}
  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"
    }'
  ```

  ```javascript Node.js theme={"dark"}
  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`);
  ```

  ```python Python theme={"dark"}
  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")
  ```
</CodeGroup>

### Example Response

```json theme={"dark"}
{
  "success": true,
  "message": "Offramp rate fetched successfully",
  "timestamp": "2024-01-01T00:00:00.000Z",
  "data": {
    "currency": "NGN",
    "channel": "BANK",
    "rate": 1408.761
  }
}
```

<Note>
  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.
</Note>

## Need Help?

<CardGroup cols={2}>
  <Card title="Email Support" icon="mail" href="mailto:contact@onswitch.xyz">
    Send us a message.
  </Card>

  <Card title="Book a call" icon="calendar" href="https://calendly.com/contact-onswitch/30min">
    Hop on a call with us.
  </Card>
</CardGroup>
