Retrieve a price: /prices

Get Price Route

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

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

Query Parameters

{
    "priceRoute": {
        "blockNumber": 19462957,
        "network": 1,
        "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "srcDecimals": 6,
        "srcAmount": "1000000000",
        "destToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "destDecimals": 18,
        "destAmount": "283341969876959340",
        "bestRoute": [
            {
                "percent": 100,
                "swaps": [
                    {
                        "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                        "srcDecimals": 6,
                        "destToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                        "destDecimals": 18,
                        "swapExchanges": [
                            {
                                "exchange": "UniswapV3",
                                "srcAmount": "1000000000",
                                "destAmount": "283341969876959340",
                                "percent": 100,
                                "poolAddresses": [
                                    "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"
                                ],
                                "data": {
                                    "path": [
                                        {
                                            "tokenIn": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                                            "tokenOut": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                                            "fee": "500",
                                            "currentFee": "500"
                                        }
                                    ],
                                    "gasUSD": "13.515820"
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "gasCostUSD": "14.656605",
        "gasCost": "118200",
        "side": "SELL",
        "version": "6.2",
        "contractAddress": "0x6a000f20005980200259b80c5102003040001068",
        "tokenTransferProxy": "0x6a000f20005980200259b80c5102003040001068",
        "contractMethod": "swapExactAmountInOnUniswapV3",
        "partnerFee": 0,
        "srcUSD": "999.4370000000",
        "destUSD": "1003.8267642998",
        "partner": "anon",
        "maxImpactReached": false,
        "hmac": "7975cda2fd343cb90f1a15d1ec11302c467a8d7d"
    }
}

Most common error messages

The following is a list of the most common error messages of the /prices endpoint. Most are self-explanatory and can be self-solved, but feel free to contact ParaSwap Support using the chat in the bottom right corner of this page.

  • Invalid route, from token should be the first token of the route

  • Invalid route, to token should be the last token of the route

  • Token not found. Please pass srcDecimals & destDecimals query params to trade any tokens -Check the doc for more details https://developers.paraswap.network/api/get-rate-for-a-token-pair

  • Invalid tokens - (srcToken and destToken) or (route) params are not passed

  • If receiver is defined userAddress should also be defined

  • It is not allowed to pass both params: "positiveSlippageToUser" and "takeSurplus". - We advice removing "positiveSlippageToUser", because it is deprecated

  • excludeDirectContractMethods param is deprecated, please use excludeContractMethodsWithoutFeeModel for newer versions

  • Invalid Amount - amount param is not a valid number

  • Validation failed: <error> - params validation failed (message has the exact reason for failure)

  • Price Timeout - reverts when a query takes more time than expected

  • No routes found with enough liquidity

  • Estimated_loss_greater_than_max_impact

  • Internal Error while computing the price - something went wrong during the price route calculation

  • Invalid max USD impact - maxUSDImpact is not a valid number

  • Error while handling price request - something went wrong during the price route calculation

Last updated