Get Rate for a Token Pair

Get Price Route

GET https://apiv5.paraswap.io/prices

This endpoint gets the optimal price and price route required to swap from one token to another.

Query Parameters

{
  "priceRoute": {
    "blockNumber": 13015909,
    "network": 1,
    "srcToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
    "srcDecimals": 0,
    "srcAmount": "1000000000000000000",
    "destToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "destDecimals": 0,
    "destAmount": "1000000000000000000",
    "bestRoute": {
      "percent": 100,
      "swaps": [
        {
          "srcToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
          "srcDecimals": 0,
          "destToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "destDecimals": 0,
          "swapExchanges": [
            {
              "exchange": "UniswapV2",
              "srcAmount": "1000000000000000000",
              "destAmount": "1000000000000000000",
              "percent": 100,
              "data": {
                "router": "0x0000000000000000000000000000000000000000",
                "path": [
                  "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                  "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
                ],
                "factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
                "initCode": "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",
                "feeFactor": 10000,
                "pools": [
                  {
                    "address": "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc",
                    "fee": 30,
                    "direction": false
                  }
                ],
                "gasUSD": "13.227195"
              }
            }
          ]
        }
      ]
    },
    "others": {
      "exchange": "UniswapV2",
      "srcAmount": "1000000000000000000",
      "destAmount": "3255989380",
      "unit": "3255989380",
      "data": {
        "router": "0x0000000000000000000000000000000000000000",
        "path": [
          "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
        ],
        "factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
        "initCode": "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",
        "feeFactor": 10000,
        "pools": [
          {
            "address": "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc",
            "fee": 30,
            "direction": false
          }
        ],
        "gasUSD": "13.227195"
      }
    },
    "gasCostUSD": "11.947163",
    "gasCost": "111435",
    "side": "SELL",
    "tokenTransferProxy": "0x3e7d31751347BAacf35945074a4a4A41581B2271",
    "contractAddress": "0x485D2446711E141D2C8a94bC24BeaA5d5A110D74",
    "contractMethod": "swapOnUniswap",
    "srcUSD": "3230.3000000000",
    "destUSD": "3218.9300566052",
    "partner": "paraswap.io",
    "partnerFee": 0,
    "maxImpactReached": false,
    "hmac": "319c5cf83098a07aeebb11bed6310db51311201f"
  }
}

🧙Though srcDecimals and destDecimals are optional parameters it is highly recommended to add them while doing the pricing. This will allow you to get prices for all the tokens, including the ones which are also not listed by ParaSwap.

Swaps fees and Swap&Transfer (where the receiver is not the same as the sender) don't work when swapOnUniswap, swapOnUniswapFork, swapOnZeroXv2, and swapOnZeroXv4 etc. contract methods are used.

If you would like to disable these methods you can do so by setting a whitelist for methods where Swap&Transfer is supportedincludeContractMethods=simpleSwap,multiSwap,megaSwap

Last updated