# Get Quote

This API returns the best quotes from yBridge

## Get the best quote for bridging tokens

<mark style="color:blue;">`GET`</mark> `endpoint/quote`

#### Query Parameters

| Name                                               | Type   | Description                           |
| -------------------------------------------------- | ------ | ------------------------------------- |
| srcChainId<mark style="color:red;">\*</mark>       | String | ID of source chain                    |
| fromTokenAddress<mark style="color:red;">\*</mark> | String | Token to be swapped from source chain |
| amount<mark style="color:red;">\*</mark>           | String | Amount of tokens to be swapped.       |
| destChainId<mark style="color:red;">\*</mark>      | String | ID of target chain                    |
| toTokenAddress<mark style="color:red;">\*</mark>   | String | Token to be received on target chain  |
|                                                    |        |                                       |

{% tabs %}
{% tab title="200: OK Swap amount not enough" %}

```javascript
{
    "isSuccess": false,
    "msg": "The minimum swap amount for this trading pair should be equivalent to {min_amount} {token_symbol}."
    "statusCode": "6",
    "destChainId": "<target chain ID>",
    "fromTokenAddress": "<address>",
    "toTokenAddress": "<address>",
    "fromTokenAmount": "<amount>",
    "contractAddress": null,
    "srcChainId": "<source chain ID>",
    "toTokenAmount": "0",
    "xyFee": null,
}
```

{% endtab %}

{% tab title="200: OK Success" %}

```javascript
{
  "isSuccess": true,
  "msg": "Quotation success.",
  "statusCode": "0",
  "destChainId": "137",
  "fromTokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  "toTokenAddress": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
  "fromTokenAmount": "1000000000",
  "toTokenAmount": "512870365878922641408",
  "fromTokenValue": 199.5,
  "toTokenValue": 199,
  "contractAddress": "0x73Ce60416035B8D7019f6399778c14ccf5C9c7A1",
  "srcChainId": "1",
  "crossChainFee": null,
  "xyFee": {
    "amount": 0.9,
    "symbol": "USDT"
  },
  "quote": {
    "sourceChainSwaps": null,
    "crossChainSwap": {
      "dexNames": [
        "yBridge"
      ],
      "fromToken": {
        "tokenAddress": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
        "chainId": "1",
        "symbol": "USDT",
        "decimals": 6
      },
      "toToken": {
        "tokenAddress": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
        "chainId": "137",
        "symbol": "USDT",
        "decimals": 6
      }
    },
    "destChainSwaps": {
      "dexNames": [
        "SushiSwap"
      ],
      "fromToken": {
        "tokenAddress": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
        "chainId": "137",
        "symbol": "USDT",
        "decimals": 6
      },
      "toToken": {
        "tokenAddress": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
        "chainId": "137",
        "symbol": "WMATIC",
        "decimals": 18
      }
    },
    "toTokenAmount": "512.8703658789226",
    "estimatedTransferTime": 270,
    "transactionCounts": 2
  }
}
```

{% endtab %}

{% tab title="200: OK No routes available" %}

```javascript
{
    "isSuccess": false,
    "msg": "Token unsupported or liquidity insufficient."
    "statusCode": "3",
    "destChainId": "<target chain ID>",
    "fromTokenAddress": "<address>",
    "toTokenAddress": "<address>",
    "fromTokenAmount": "<amount>",
    "contractAddress": null,
    "srcChainId": "<source chain ID>",
    "toTokenAmount": "0",
    "xyFee": null,
}
```

{% endtab %}

{% tab title="200: OK Bridge liquidity not enough" %}

```javascript
{
    "isSuccess": false,
    "msg": "yBridge liquidity insufficient."
    "statusCode": "4",
    "destChainId": "<target chain ID>",
    "fromTokenAddress": "<address>",
    "toTokenAddress": "<address>",
    "fromTokenAmount": "<amount>",
    "contractAddress": null,
    "srcChainId": "<source chain ID>",
    "toTokenAmount": "0",
    "xyFee": null,
}
```

{% endtab %}

{% tab title="200: OK Route engine temporary timeout" %}

```javascript
{
    "isSuccess": false,
    "msg": "Request for route-fetching has timed out. Please try again."
    "statusCode": "5",
    "destChainId": "<target chain ID>",
    "fromTokenAddress": "<address>",
    "toTokenAddress": "<address>",
    "fromTokenAmount": "<amount>",
    "contractAddress": null,
    "srcChainId": "<source chain ID>",
    "toTokenAmount": "0",
    "xyFee": null,
}
```

{% endtab %}
{% endtabs %}

### Parameter/Response Details

* Use `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` as the address for the native token in your parameter.
* Note that the amount parameter should be padded with zeroes. For example, pass **100000000** instead of **100** if the decimal digits of the token are 6.

### Example Request

<pre class="language-shell"><code class="lang-shell"><strong>$ curl https://open-api.xy.finance/v1/quote?srcChainId=1&#x26;fromTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&#x26;amount=500000000000000000&#x26;destChainId=56&#x26;toTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
</strong></code></pre>

This request is asking a quote of **0.5 ETH** on **Ethereum** to **BNB** on **BSC**.

{% hint style="warning" %}
**`IMPORTANT:`**` ``Note that the amount parameter should be padded with zeroes. For example, pass`` `**`100000000`**` ``instead of`` `**`100`**` ``if the decimals of the token is 6.`
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xy.finance/single-bridge-integration/ybridge-api/get-quote.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
