Get Rate for a Token Pair

get
Get Price Route

https://apiv5.paraswap.io/prices
This endpoint gets the optimal price and price route required to swap from one token to another.
Request
Response
Request
Query Parameters
srcToken
required
string
Source Token Address. Instead Token Symbol could be used for tokens listed in the /tokens endpoint.
srcDecimals
optional
integer
Source Token Decimals. (Can be omitted if Token Symbol is used in srcToken).
destToken
required
string
Destination Token Address. Instead Token Symbol could be used for tokens listed in the /tokens endpoint.
amount
required
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
optional
string
SELL or BUY. Default: SELL.
network
optional
string
Network ID . (Mainnet - 1, Ropsten - 3, Polygon - 137, BSC - 56, Avalanche - 43114 ). Default: 1.
otherExchangePrices
optional
boolean
If provided, others object is filled in the response with price quotes from other exchanges (if available for comparison). Default: false
includeDEXS
optional
string
Comma Separated List of DEXs to include. Supported DEXs: Uniswap, Kyber, Bancor, Oasis, Compound, Fulcrum, 0x, MakerDAO, Chai, ParaSwapPool, Aave, Aave2, MultiPath, MegaPath, Curve, Curve3, Saddle, IronV2, BDai, idle, Weth, Beth, UniswapV2, Balancer, 0xRFQt, ParaSwapPool2, ParaSwapPool3, ParaSwapPool4, ParaSwapPool5, ParaSwapPool6, SushiSwap, LINKSWAP, Synthetix, DefiSwap, Swerve, CoFiX, Shell, DODOV1, DODOV2, OnChainPricing, PancakeSwap, PancakeSwapV2, ApeSwap, Wbnb, acryptos, streetswap, bakeryswap, julswap, vswap, vpegswap, beltfi, ellipsis, QuickSwap, COMETH, Wmatic, Nerve, Dfyn, UniswapV3, Smoothy, PantherSwap, OMM1, OneInchLP, CurveV2, mStable, WaultFinance, MDEX, ShibaSwap, CoinSwap, SakeSwap, JetSwap, Biswap, BProtocol eg: UniswapV3,0x
excludeDEXS
optional
boolean
Comma Separated List of DEXs to exclude. (from the list of DEXs mentioned above).
includeContractMethods
optional
string
Comma Separated List of Contract Methods to include without spaces. Available values: swapOnUniswap, buyOnUniswap, swapOnUniswapFork, buyOnUniswapFork, swapOnUniswapV2Fork, buyOnUniswapV2Fork, simpleBuy, simpleSwap, multiSwap, megaSwap, protectedMultiSwap, protectedMegaSwap, protectedSimpleSwap, protectedSimpleBuy, swapOnZeroXv2, swapOnZeroXv4, buy. eg: simpleSwap,multiSwap
excludeContractMethods
optional
string
Comma Separated List of Contract Methods to exclude without spaces. (from the list of contract methods mentioned above).
userAddress
optional
string
User's Wallet Address.
route
optional
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
optional
string
Partner string.
Response
200: OK
Successful Price Response.
{
"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"
}
}
400: Bad Request
Price Error
{
"error": "computePrice Error

🧙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