Rango Docs
API SwaggerWidget PlaygroundAppWebsite
  • 👋Welcome to Rango
  • 🏠Introduction
  • 💁How It Works
  • ✅Integrations
  • ⚖️Rango vs. Competitors
  • 🔐Security
  • 🛣️Roadmap
  • 🦎Tokenomics
  • 💰Airdrop
  • ❓FAQ
  • 🐞Bug Bounty
  • API Integration
    • 🔡Terminology
    • 🚄API Key & Rate Limits
    • 🤝Choosing the Right API
    • 🦄Basic API - Single Step
      • 🛝API Flow
      • ⚙️API Reference
        • Get Blockchains & Tokens
        • Get Quote
        • Create Transaction (Swap)
        • Check Transaction Status
        • Check Approve Transaction Status
        • Get Address Assets & Balances
        • Get Token Balance
        • Report Transaction Failure
        • Get Direct Tokens
        • Get Custom Token
        • Message Passing
      • 🎓Tutorial
        • 🍰SDK Example
      • 💰Monetization
      • 🎹Sample Transactions
      • ✅Integration Checklist
    • 🦎Main API - Multi Step
      • 🛝API Flow
      • ⚙️API Reference
        • Get Blockchains & Tokens
        • Get Best Route
        • Get All Possible Routes
        • Confirm Route
        • Create Transaction
        • Check Transaction Status
        • Check Approve Transaction Status
        • Report Transaction Failure
        • Get Custom Token
        • Get Address Token Balance
      • 🎓Tutorial
        • 🍰SDK Example
      • 💰Monetization
      • 🎹Sample Transactions
  • ℹ️API Troubleshooting
  • Technical Docs
    • 🍔Swap Aggregation
    • 💰Monetization
    • ⛽Fee Structure
    • ⛽Network Fees and Gas Estimates
    • ⌛Stuck Transactions
  • Widget Integration
    • 🧩Overview
    • 🎇Quick Start
    • ⚙️Customization
    • 💰Monetization
    • 🛣️React Router
    • 🎵Events
    • 💳External Wallets
  • Smart Contracts
    • 👩‍💼Architecture
    • 🔎Audit Reports
    • 🏗️Deployment Addresses
    • 📩Message Passing
  • Ask for Integration
    • 🙋‍♂️DEXs & DEX Aggregators
    • 📱Rango Mobile SDK
  • Useful Links
    • Twitter
    • Discord Server
    • TG Announcements
    • TG Group
  • Terms of Use
  • Privacy policy
Powered by GitBook
On this page
  • Quote API
  • Quote Request
  • Quote Response

Was this helpful?

  1. API Integration
  2. Basic API - Single Step
  3. API Reference

Get Quote

Get the best single-step route for swapping X to Y

PreviousGet Blockchains & TokensNextCreate Transaction (Swap)

Last updated 7 months ago

Was this helpful?

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.

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
})
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'
  }
});
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' 

Quote Request

  • from * String

    • Example: BSC.BNB

  • to * String

    • Example: AVAX_CCHAIN--0xc7198437980c041c805a1edcba50c1ce5db95118

  • amount * String

    • 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

  • 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.

export type QuoteRequest = {
  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
}

Quote Response

  • 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.

    • Example: d10657ce-b13a-405c-825b-b47f8a5016ad

  • resultType

    • Description: Status of the route.

    • Possible Values:

      • 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.

      • 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

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[]
}
{
  "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
}

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.

{
  // other fields ...,
  "amountRestriction": {
    "min": "40666469010361176",
    "max": "67777448350601960000000",
    "type": "INCLUSIVE"
  },
}

Fee (Expense Type)

These are two possible types of fees (expenseType field in the route.fee array).

  • 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.

{
  // other fields ...,
  "feeUsd": 0.2527750142059618,
  "fee": [
      {
        "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"
        }
      },
  ],
}

Description: The source

Description: The destination

Description: The machine readable amount of X that is going to be swapped

Description:

🦄
⚙️
Quote (Get Best Route)rango-exchange
Get Quote Swagger Link
Logo
asset
asset
asset
Referrer code