# Get Quote

## Quote API

Using the quote method, you can get a preview of the best route for this cross-chain swap. It goes through all the possible DEXs, bridges and aggregators to find the best possible single-step route based on user experience, fee amount, and swap output.

{% tabs %}
{% tab title="Typescript (SDK)" %}

```typescript
const quote = await rango.quote({
    from: {"blockchain": "BSC", "address": null},
    to: {"blockchain": "AVAX_CCHAIN", "address": "0xc7198437980c041c805a1edcba50c1ce5db95118"},
    amount: "100000000000000000", // 0.1 BSC.BNB
    slippage: 1.5
})
```

{% endtab %}

{% tab title="Node.js (Axios)" %}

```javascript
const response = await axios.get('https://api.rango.exchange/basic/quote', {
  params: {
    'from': 'BSC.BNB',
    'to': 'AVAX_CCHAIN--0xc7198437980c041c805a1edcba50c1ce5db95118',
    'amount': '100000000000000000',
    'slippage': 1.5,
    'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32'
  }
});
```

{% endtab %}

{% tab title="Bash (cURL)" %}

```bash
curl --request GET \
     --url 'https://api.rango.exchange/basic/quote?from=BSC.BNB&to=AVAX_CCHAIN--0xc7198437980c041c805a1edcba50c1ce5db95118&slippage=1.5&amount=100000000000000000&apiKey=c6381a79-2817-4602-83bf-6a641a409e32' 
```

{% endtab %}
{% endtabs %}

{% embed url="<https://rango-api.readme.io/reference/quote>" %}
Get Quote Swagger Link
{% endembed %}

### Quote Request&#x20;

{% tabs %}
{% tab title="API Definition" %}

* **`from`** <mark style="color:red;">\*</mark> String
  * Description: The source [asset](https://docs.rango.exchange/terminology#asset-token)
  * Example: `BSC.BNB`
* **`to`** <mark style="color:red;">\*</mark> String
  * Description: The destination [asset](https://docs.rango.exchange/terminology#asset-token)
  * Example: `AVAX_CCHAIN--0xc7198437980c041c805a1edcba50c1ce5db95118`
* **`amount`** <mark style="color:red;">\*</mark> String
  * Description: The machine readable amount of [asset](https://docs.rango.exchange/terminology#asset-token) X that is going to be swapped
  * Example:  `100000000000000000000` for 100 Fantom.FTM
* **`slippage`** Number
  * Description: Amount of user's preferred slippage in percent. if you don't send it, it will assume 0.5% slippage. It's used to filter the swappers or routes that are not suitable for the given slippage.
  * Example: `1.5` means 1.5% slippage
* **`referrerCode`** String
  * Description: [Referrer code](https://docs.rango.exchange/terminology#affiliate-ref-referrer-code)
* **`referrerFee`** String
  * Description: Referrer fee in percent
* **`swappers`** String
  * Description: List of all accepted swappers, an empty list means no filter is required.
* **`swappersExclude`** Boolean
  * Description: Defines the provided swappers as the include/exclude list. Default is false (include)
* **`swapperGroups`** String
  * Description: The list of all included/excluded swappers based on tag. Empty list means no filter is required.
* **`swappersGroupsExclude`** Boolean
  * Description: Defines the provided swappers' tags as the include/exclude list. Default is false (include)
* **`contractCall`** Boolean
  * Description: Set this parameter to `true` if you want to send transactions through a contract. It will filter swappers that are not possible to be called by another contract.
  * **Caution:** If you call Rango contracts using your contract and your contract is not white listed in some underlying protocols like Thorchain, user fund may stuck forever in Thorchain contracts. In this case, you need to exclude these swappers using this flag or ask related protocols to white list your contracts.
* **`sourceContract`** String
  * Description: Address of your contract on source chain (will be called in case of refund in the source chain)
* **`destinationContract`** String
  * Description: Address of your contract on destination chain (will be called in case of success/refund in the destination chain)
* **`imMessage`** String
  * Description: The message that you want to pass to your contract on the destination chain.
* **`messagingProtocols`** String
  * Description: Message protocols which will be used to relay message in a cross-chain swap. An empty list means no filter is required.
* **`avoidNativeFee`** Boolean
  * Description: When this condition is true, swappers that charge fees in native tokens will be excluded. For instance, when called from an AA account.
  * **Caution:** Swappers like Stargate charge user fees in native tokens instead of the input amount, causing the transaction value to differ from the user's input amount. Alternatively, the user may need to transfer native tokens in a contract call to cover these protocol fees. Although you can disable these protocols using this flag, we do not recommend it as it reduces the coverage of single-step routes.
* **`enableCentralizedSwappers`** Boolean
  * Description: Pass this flag true if you want to enable routing through the centralized solutions. Default is false.
  * **Caution:** To enable these swappers, you must pass the user's IP to the Rango API for compliance checks. Additionally, user funds may be held for KYC if their wallet is flagged as risky by the screening solutions implemented by these protocols.
    {% endtab %}

{% tab title="SDK Models (Typescript)" %}

<pre class="language-typescript"><code class="lang-typescript"><strong>export type QuoteRequest = {
</strong>  from: RequestedAsset
  to: RequestedAsset
  amount: string
  slippage?: number
  swappers?: string[]
  swappersExclude?: boolean
  swapperGroups?: string[]
  swappersGroupsExclude?: boolean
  messagingProtocols?: string[]
  sourceContract?: string
  destinationContract?: string
  imMessage?: string
  contractCall?: boolean
  enableCentralizedSwappers?: boolean
  avoidNativeFee?: boolean
  referrerCode?: string
  referrerFee?: number
}

export type RequestedAsset = {
  blockchain: string
  address: string | null
  symbol?: string
}
</code></pre>

{% endtab %}
{% endtabs %}

### Quote Response&#x20;

{% tabs %}
{% tab title="API Definition" %}

* **`requestId`**
  * Description: The unique request Id which is generated for this request by the server. It should be passed down to all other endpoints if this swap continues on.&#x20;
  * Example: `d10657ce-b13a-405c-825b-b47f8a5016ad`
* **`resultType`**
  * Description: Status of the route.
  * Possible Values:&#x20;
    * `OK` => Best route found. Everything is OK.
    * `HIGH_IMPACT` => The route has high price impact, we recommend not proceeding with the next step. The Rango API may give you an error in the next step to prevent potential losses.&#x20;
    * `INPUT_LIMIT_ISSUE` => There is a limit issue for the input amount. You could suggest user to increase or decrease the input amount based on `amountRestrictions` field in response.
    * `NO_ROUTE` => No routes found.
* **`route`**
  * Description: The quote route object
    {% endtab %}

{% tab title="SDK Models (Typescript)" %}

```typescript
export type QuoteResponse = {
  requestId: string
  resultType: RoutingResultType
  route: QuoteSimulationResult | null
  error: string | null
  errorCode: number | null
  traceId: number | null
}

export enum RoutingResultType {
  OK = 'OK',
  HIGH_IMPACT = 'HIGH_IMPACT',
  NO_ROUTE = 'NO_ROUTE',
  INPUT_LIMIT_ISSUE = 'INPUT_LIMIT_ISSUE',
  HIGH_IMPACT_FOR_CREATE_TX = 'HIGH_IMPACT_FOR_CREATE_TX',
}

export type QuoteSimulationResult = {
  from: Token
  to: Token
  outputAmount: string
  outputAmountMin: string
  outputAmountUsd: number | null
  swapper: SwapperMeta
  path: QuotePath[] | null
  fee: SwapFee[]
  feeUsd: number | null
  amountRestriction: AmountRestriction | null
  estimatedTimeInSeconds: number
}

export type AmountRestriction = {
  min: string | null
  max: string | null
  type: AmountRestrictionType
}

export type SwapFee = {
  name: string
  token: Token
  expenseType: ExpenseType
  amount: string
  meta: EVMFeeMeta | null
}

export type ExpenseType =
  | 'FROM_SOURCE_WALLET'
  | 'DECREASE_FROM_OUTPUT'
  | 'FROM_DESTINATION_WALLET'
  
export type SwapperMeta = {
  id: string
  title: string
  logo: string
  swapperGroup: string
  types: SwapperType[]
  enabled: boolean
}

export type SwapperType = 'BRIDGE' | 'DEX' | 'AGGREGATOR' | 'OFF_CHAIN'

export type QuotePath = {
  from: Token
  to: Token
  swapper: SwapperMeta
  swapperType: SwapperType
  inputAmount: string
  expectedOutput: string
  estimatedTimeInSeconds: number
}

export type Token = {
  blockchain: string
  chainId: string | null
  address: string | null
  symbol: string
  name: string | null
  decimals: number
  image: string
  blockchainImage: string
  usdPrice: number | null
  isPopular: boolean
  supportedSwappers: string[]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
  "requestId": "50365411-295c-4431-8ade-d848f84c46f2",
  "resultType": "OK",
  "route": {
    "outputAmount": "50348915",
    "outputAmountMin": "49593681",
    "outputAmountUsd": 50.44961283,
    "swapper": {
      "id": "Bridgers",
      "title": "Bridgers",
      "logo": "https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/Bridgers/icon.svg",
      "swapperGroup": "Bridgers",
      "types": [
        "DEX",
        "BRIDGE"
      ],
      "enabled": true
    },
    "from": {
      "blockchain": "BSC",
      "symbol": "BNB",
      "name": null,
      "isPopular": false,
      "chainId": "56",
      "address": null,
      "decimals": 18,
      "image": "https://rango.vip/tokens/ALL/BNB.png",
      "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
      "usdPrice": 513.49,
      "supportedSwappers": []
    },
    "to": {
      "blockchain": "AVAX_CCHAIN",
      "symbol": "USDT.E",
      "name": null,
      "isPopular": false,
      "chainId": "43114",
      "address": "0xc7198437980c041c805a1edcba50c1ce5db95118",
      "decimals": 6,
      "image": "https://rango.vip/i/GJxbOP",
      "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/AVAX_CCHAIN/icon.svg",
      "usdPrice": 1.002,
      "supportedSwappers": []
    },
    "fee": [
      {
        "token": {
          "blockchain": "BSC",
          "symbol": "BNB",
          "name": "BNB",
          "isPopular": true,
          "chainId": "56",
          "address": null,
          "decimals": 18,
          "image": "https://rango.vip/tokens/ALL/BNB.png",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 513.49,
          "supportedSwappers": [
            "ThorChain",
            "XO Swap",
            "ParaSwap Bsc",
            "OneInchBsc",
            "SWFT",
            "BSCPancakeV3",
            "Bridgers",
            "Satellite",
            "PancakeSwapBsc",
            "ThorChainStreamingSwap"
          ]
        },
        "expenseType": "DECREASE_FROM_OUTPUT",
        "amount": "299550000000000",
        "name": "Swapper Fee"
      },
      {
        "token": {
          "blockchain": "BSC",
          "symbol": "BNB",
          "name": "BNB",
          "isPopular": true,
          "chainId": "56",
          "address": null,
          "decimals": 18,
          "image": "https://rango.vip/tokens/ALL/BNB.png",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 513.49,
          "supportedSwappers": [
            "ThorChain",
            "XO Swap",
            "ParaSwap Bsc",
            "OneInchBsc",
            "SWFT",
            "BSCPancakeV3",
            "Bridgers",
            "Satellite",
            "PancakeSwapBsc",
            "ThorChainStreamingSwap"
          ]
        },
        "expenseType": "DECREASE_FROM_OUTPUT",
        "amount": "150000000000000",
        "name": "Rango Fee"
      },
      {
        "token": {
          "blockchain": "BSC",
          "symbol": "BNB",
          "name": "BNB",
          "isPopular": true,
          "chainId": "56",
          "address": null,
          "decimals": 18,
          "image": "https://rango.vip/tokens/ALL/BNB.png",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 513.49,
          "supportedSwappers": [
            "ThorChain",
            "XO Swap",
            "ParaSwap Bsc",
            "OneInchBsc",
            "SWFT",
            "BSCPancakeV3",
            "Bridgers",
            "Satellite",
            "PancakeSwapBsc",
            "ThorChainStreamingSwap"
          ]
        },
        "expenseType": "FROM_SOURCE_WALLET",
        "amount": "168748800000000",
        "name": "Network Fee",
        "meta": {
          "type": "EvmNetworkFeeMeta",
          "gasLimit": "153408",
          "gasPrice": "1100000000"
        }
      }
    ],
    "feeUsd": 0.086650821312,
    "amountRestriction": {
      "min": "38760000000000000",
      "max": "3893361000000000000",
      "type": "EXCLUSIVE"
    },
    "estimatedTimeInSeconds": 360,
    "path": [
      {
        "swapper": {
          "id": "Bridgers",
          "title": "Bridgers",
          "logo": "https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/Bridgers/icon.svg",
          "swapperGroup": "Bridgers",
          "types": [
            "DEX",
            "BRIDGE"
          ],
          "enabled": true
        },
        "swapperType": "BRIDGE",
        "from": {
          "blockchain": "BSC",
          "symbol": "BNB",
          "name": null,
          "isPopular": false,
          "chainId": "56",
          "address": null,
          "decimals": 18,
          "image": "https://rango.vip/tokens/ALL/BNB.png",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 513.49,
          "supportedSwappers": []
        },
        "to": {
          "blockchain": "AVAX_CCHAIN",
          "symbol": "USDT.E",
          "name": null,
          "isPopular": false,
          "chainId": "43114",
          "address": "0xc7198437980c041c805a1edcba50c1ce5db95118",
          "decimals": 6,
          "image": "https://rango.vip/i/GJxbOP",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/AVAX_CCHAIN/icon.svg",
          "usdPrice": 1.002,
          "supportedSwappers": []
        },
        "inputAmount": "100000000000000000",
        "expectedOutput": "50348915",
        "estimatedTimeInSeconds": 360
      }
    ]
  },
  "error": null,
  "errorCode": null,
  "traceId": null
}
```

{% endtab %}
{% endtabs %}

#### Limits (Amount Restriction)

The `route.amountRestriction` field indicates the minimum and maximum possible input amount for this quote. `EXCLUSIVE` field means that `min<input<max` and `INCLUSIVE` means `min<=input<=max`.

<pre class="language-json"><code class="lang-json">{
  // other fields ...,
<strong>  "amountRestriction": {
</strong>    "min": "40666469010361176",
    "max": "67777448350601960000000",
    "type": "INCLUSIVE"
  },
}
</code></pre>

#### Fee (Expense Type)

These are two possible types of fees (`expenseType` field in the `route.fee` array).&#x20;

* `FROM_SOURCE_WALLET`
  * Description: The gas fee. This fee should be available in the user's wallet for the swap to succeed.
* `DECREASE_FROM_OUTPUT`
  * Some hidden fees in swapper which will be reduced from the user's output amount automatically. This fee is already calculated in the estimated output.

And this is a sample fee object you get through the `quote/swap` endpoint. You could show the user `feeUsd` amount as the total fee he/she should pay for this route.

<pre class="language-json"><code class="lang-json">{
  // other fields ...,
<strong>  "feeUsd": 0.2527750142059618,
</strong><strong>  "fee": [
</strong>      {
        "token": {
          "blockchain": "BSC",
          "symbol": "BNB",
          "name": null,
          "isPopular": true,
          "chainId": "56",
          "address": null,
          "decimals": 18,
          "image": "https://rango.vip/tokens/ALL/BNB.png",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 585.3830924582086,
          "supportedSwappers": [
            "ThorChain"
          ]
        },
        "expenseType": "FROM_SOURCE_WALLET",
        "amount": "784565100000000",
        "name": "Network Fee",
        "meta": {
          "type": "EvmNetworkFeeMeta",
          "gasLimit": "713241",
          "gasPrice": "1100000000"
        }
      },
  ],
}
</code></pre>
