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

NameTypeDescription

srcToken*

string

Source Token Address. Instead Token Symbol could be used for tokens listed in the /tokens endpoint.

srcDecimals*

integer

Source Token Decimals. (Can be omitted if Token Symbol is used in srcToken).

destToken*

string

Destination Token Address. Instead Token Symbol could be used for tokens listed in the /tokens endpoint.

amount*

string

srcToken amount (in case of SELL) or destToken amount (in case of BUY). The amount should be in WEI/Raw units (eg. 1WBTC -> 100000000)

side

string

SELL or BUY. Default: SELL.

network

string

Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100). Default: 1.

otherExchangePrices

boolean

If provided, others object is filled in the response with price quotes from other exchanges (if available for comparison). Default: false

includeDEXS

string

Comma Separated List of DEXs to include. All supported DEXs by chain can be found here eg: UniswapV3, CurveV1

excludeDEXS

string

Comma Separated List of DEXs to exclude. All supported DEXs by chain can be found here eg: UniswapV3, CurveV1

excludeRFQ

boolean

Exclude all RFQs from pricing eg: AugustusRFQ, Hashflow Default: false

includeContractMethods

string

Comma Separated List of Comma Separated List of Contract Methods to include in pricing (without spaces). View the list of the supported methods for V5 and V6 eg: swapExactAmountIn,swapExactAmountInOnUniswapV2

excludeContractMethods

string

Comma Separated List of Contract Methods to exclude from pricing (without spaces). View the list of the supported methods for V5 and V6

userAddress

string

User's Wallet Address.

route

string

Dash (-) separated list of tokens (addresses or symbols from /tokens) to comprise the price route. Max 4 tokens. *Note: If route is specified, the response will only comprise of the route specified which might not be the optimal route.

partner

string

Partner string.

destDecimals*

integer

Destination Token Decimals. (Can be omitted if Token Symbol is used in destToken).

maxImpact

number

In %. It's a way to bypass the API price impact check (default = 15%).

receiver

String

Receiver's Wallet address. (Can be omitted if swapping tokens from and to same account)

srcTokenTransferFee

string

If the source token is a tax token, you should specify the tax amount in BPS.

*For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

**Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

destTokenTransferFee

string

If the destination token is a tax token, you should specify the tax amount in BPS.

*For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

**Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

srcTokenDexTransferFee

string

If the source token is a tax token, you should specify the tax amount in BPS. Some tokens only charge tax when swapped in/out DEXs and not on ordinary transfers.

*For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

**Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

destTokenDexTransferFee

string

If the destination token is a tax token, you should specify the tax amount in BPS. Some tokens only charge tax when swapped in/out DEXs, not on ordinary transfers.

*For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

**Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

version

number

To specify the protocol version. Values: 5 or 6.2 Default: 5

excludeContractMethodsWithoutFeeModel

boolean

Specify that methods without fee support should be excluded from the price route. Default: false

ignoreBadUsdPrice

boolean

If tokens USD prices are not available, Bad USD Price error will be thrown. Use this param to skip this check. Default: false

{
    "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