> For the complete documentation index, see [llms.txt](https://docs.bindpay.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bindpay.xyz/api/request-quote.md).

# Request Quote

API Documentation for the requesting quotes - don't hesitate to reach out for additional support at support\@bindpay.xyz

**Endpoint**

```
POST https://api.bindpay.xyz/v1/quote
```

**Headers**

| Header       | Value            | Description                            |
| ------------ | ---------------- | -------------------------------------- |
| Content-Type | application/json | The content type of the request body   |
| x-api-key    | Your API key     | Your unique API key for authentication |

{% hint style="info" %}
Do you have an API key yet? Register for one [here](https://app.bindpay.xyz)
{% endhint %}

#### Request Body

| Field       | Type   | Description                                |
| ----------- | ------ | ------------------------------------------ |
| fromChain   | string | The chain ID of the source blockchain      |
| fromToken   | string | The token address on the source blockchain |
| fromAddress | string | The wallet address of the payer            |
| usdAmount   | string | The transaction amount in USD              |

**Notes**

* No need to worry about filling in your own settlement details - we use the settlement information you provided within the developer portal - [https://app.bindpay.xyz](https://app.bindpay.xyz/login)
* The fromChain should be a valid chain ID. Refer to the Active Chains documentation for supported networks - [Active Chains](/active-chains.md)
* The fromToken should be the token address on the source blockchain.
* The API uses rate limiting to prevent abuse. You are limited to 10 quote requests per 5 minutes per IP address. Get in touch to increase limit - <support@bindpay.xyz>

#### Example Request

{% tabs %}
{% tab title="cURL" %}
{% code lineNumbers="true" %}

```javascript
curl -X POST "https://api.bindpay.xyz/v1/quote" \
     -H "Content-Type: application/json" \
     -H "x-api-key: your_api_key_here" \
     -d '{
       "fromChain": "1", //Eth Chain ID
       "fromToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", //USDC 
       "fromAddress": "0x742d35Cc6634C0532925a3b844Bc45426438f000",
       "usdAmount": 100
     }'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests

url = "https://api.bindpay.xyz/v1/quote"
headers = {
    "Content-Type": "application/json",
    "x-api-key": "your_api_key_here"
}
data = {
    "fromChain": "1",
    "fromToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "fromAddress": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "usdAmount": 100
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
```

{% endcode %}
{% endtab %}

{% tab title="Rust" %}
{% code lineNumbers="true" %}

```rust
use reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let url = "https://api.bindpay.xyz/v1/quote";
    let client = Client::new();

    let response = client.post(url)
        .header("Content-Type", "application/json")
        .header("x-api-key", "your_api_key_here")
        .json(&json!({
            "fromChain": "1",
            "fromToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
            "fromAddress": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
            "usdAmount": 100
        }))
        .send()
        .await?;

    println!("{}", response.text().await?);
    Ok(())
}
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
require 'net/http'
require 'uri'
require 'json'

uri = URI('https://api.bindpay.xyz/v1/quote')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri, 
    'Content-Type' => 'application/json',
    'x-api-key' => 'your_api_key_here'
)
request.body = {
    fromChain: '1',
    fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
    fromAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
    usdAmount: 100
}.to_json

response = http.request(request)
puts response.body
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
const axios = require('axios');

const url = 'https://api.bindpay.xyz/v1/quote';
const headers = {
    'Content-Type': 'application/json',
    'x-api-key': 'your_api_key_here'
};
const data = {
    fromChain: '1',
    fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
    fromAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
    usdAmount: 100
};

axios.post(url, data, { headers })
    .then(response => console.log(response.data))
    .catch(error => console.error('Error:', error));
```

{% endcode %}
{% endtab %}

{% tab title="TypeScript" %}
{% code lineNumbers="true" %}

```typescript
import axios from 'axios';

const url = 'https://api.bindpay.xyz/v1/quote';
const headers = {
    'Content-Type': 'application/json',
    'x-api-key': 'your_api_key_here'
};
const data = {
    fromChain: '1',
    fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 
    fromAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
    usdAmount: 100
};

axios.post(url, data, { headers })
    .then(response => console.log(response.data))
    .catch(error => console.error('Error:', error));
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

The API will respond with a JSON object containing the quote details.

**Successful Response**

```json
{
  "message": "Quote requested",
  "transactionId": "6729a49048ad67c3a3611163",
  "quote": {
    // Quote & Provider details
  },
  "approvalTxParams": {
    // Approval transaction parameters 
  },
  "transactionRequest": {
    // Transaction request details
  }
}
```

#### Notes

* Quote Provider: The response includes details from the selected quote provider (e.g., LiFi, 1inch, or internal routing).
* Approval Transaction: approvalTxParams is only present if token approval is required.
* Chain IDs: Refer to [Active Chains](/active-chains.md).
* Gas Estimates: Based on current network conditions and may change.
* Quote Expiration: Quotes have a limited validity period.
* Slippage: The actual received amount may differ due to price fluctuations.
* Cross-Chain Transfers: For multi-chain transactions, additional monitoring steps may be required.
* Response Variation: Structure may vary slightly based on the selected provider and transfer type (direct or cross-chain).
* Best Quote Selection: The API automatically selects the most optimal quote from available providers.

| Status Code | Error Type            | Description                                                                                                             |
| ----------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| 400         | Bad Request           | The request was invalid or cannot be served. This occurs when the API key is missing or the request body is incomplete. |
| 401         | Unauthorized          | The request requires authentication. This happens when the API key is invalid.                                          |
| 404         | Not Found             | The requested resource could not be found. This occurs when the business associated with the API key is not found.      |
| 429         | Too Many Requests     | The user has sent too many requests in a given amount of time. This is triggered by the rate limiter.                   |
| 500         | Internal Server Error | The server encountered an unexpected condition that prevented it from fulfilling the request.                           |

#### Error Handling

* If the API key is missing or invalid, you will receive a 400 or 401 error response.
* If the rate limit is exceeded, you will receive a 429 error response.
* For other errors, appropriate HTTP status codes and error messages will be returned.

For more information on error handling and response codes, please refer to our Error Handling documentation or get in contact with <support@bindpay.xyz>.
