> For the complete documentation index, see [llms.txt](https://ivorypay.gitbook.io/ivorypay-on-off-ramp-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ivorypay.gitbook.io/ivorypay-on-off-ramp-documentation/api-reference-exchange-rates/onramp-rate.md).

# Get On-Ramp Exchange Rate

Get a fee breakdown and crypto conversion for a proposed on-ramp transaction.

Returns the platform fee, business fee, gas fee, and crypto amount breakdown for a fiat-to-crypto on-ramp before initiating a transaction.

## Endpoint

```
POST /v1/exchange-rates/onramp
```

## Authentication

Requires a Merchant API key in the `Authorization` header.

```
Authorization: <api_key>
```

## Request body

| Field               | Type   | Required | Description                                                                                                                          |
| ------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `fiatAmount`        | number | Yes      | Amount in fiat the customer will pay                                                                                                 |
| `businessFeeInFiat` | number | Yes      | Your business fee in fiat. Send `0` if not charging a fee                                                                            |
| `fiatCurrency`      | string | Yes      | Fiat currency. See [Supported Currencies](/ivorypay-on-off-ramp-documentation/resources/supported-currencies.md)                     |
| `token`             | string | Yes      | Cryptocurrency to receive. See [Supported Networks & Tokens](/ivorypay-on-off-ramp-documentation/resources/supported-blockchains.md) |
| `blockchain`        | string | Yes      | Blockchain network. See [Supported Blockchains](/ivorypay-on-off-ramp-documentation/resources/supported-blockchains.md)              |

## Example request

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST https://ramp-api.ivorypay.io/api/v1/exchange-rates/onramp \
  -H "Authorization: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "fiatAmount": 50000,
    "businessFeeInFiat": 0,
    "fiatCurrency": "NGN",
    "token": "USDT",
    "blockchain": "BSC_MAINNET"
  }'
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const response = await fetch("https://ramp-api.ivorypay.io/api/v1/exchange-rates/onramp", {
  method: "POST",
  headers: {
    "Authorization": "your_api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    fiatAmount: 50000,
    businessFeeInFiat: 0,
    fiatCurrency: "NGN",
    token: "USDT",
    blockchain: "BSC_MAINNET",
  }),
});

const data = await response.json();
console.log(data);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

response = requests.post(
    "https://ramp-api.ivorypay.io/api/v1/exchange-rates/onramp",
    headers={
        "Authorization": "your_api_key",
        "Content-Type": "application/json",
    },
    json={
        "fiatAmount": 50000,
        "businessFeeInFiat": 0,
        "fiatCurrency": "NGN",
        "token": "USDT",
        "blockchain": "BSC_MAINNET",
    },
)

print(response.json())
```

{% endtab %}
{% endtabs %}

## Example response

```json
{
  "success": true,
  "message": "Query successful",
  "data": {
    "platformFeeInFiat": 250,
    "businessFeeInFiat": 0,
    "platformFeeInCrypto": 0.156,
    "gasFee": 0.5,
    "cryptoRate": 1600,
    "fiatRate": 1600,
    "businessFeeInCrypto": 0,
    "fiatAmountPayable": 50250,
    "cryptoAmount": 31.25,
    "cryptoAmountLessFee": 30.594,
    "fiatCurrency": "NGN",
    "token": "USDT",
    "blockchain": "BSC_MAINNET"
  }
}
```

## Response fields

| Field                 | Type   | Description                                          |
| --------------------- | ------ | ---------------------------------------------------- |
| `platformFeeInFiat`   | number | IvoryPay's platform fee in fiat                      |
| `platformFeeInCrypto` | number | IvoryPay's platform fee in crypto                    |
| `businessFeeInFiat`   | number | Your business fee in fiat                            |
| `businessFeeInCrypto` | number | Your business fee in crypto                          |
| `gasFee`              | number | Estimated gas fee in crypto                          |
| `fiatRate`            | number | Fiat units per 1 crypto token                        |
| `cryptoRate`          | number | Crypto rate used for conversion                      |
| `fiatAmountPayable`   | number | Total fiat amount the customer pays (including fees) |
| `cryptoAmount`        | number | Gross crypto amount before fees                      |
| `cryptoAmountLessFee` | number | Net crypto amount the customer receives              |
| `fiatCurrency`        | string | Fiat currency code                                   |
| `token`               | string | Cryptocurrency token                                 |
| `blockchain`          | string | Blockchain network                                   |
