Get Price & Calldata: /swap
The /swap endpoint allows you to make one API call to get both the priceRoute object as well as the Transaction Object.
Limitations
Lower rate limits
It doesn't check sufficient allowances and balances
It doesn't return the gas field in txParams, thus the transaction should be simulated locally
It automatically excludes RFQ-based DEXs such as AugustusRFQ & ParaSwapLimitOrders.
Get Price Route
GET
https://api.paraswap.io/swap
This endpoint gets the optimal price and price route required to swap from one token to another.
Query Parameters
Name | Type | Description |
---|---|---|
srcToken* | string | Source Token Address. Instead Token Symbol could be used for tokens listed in the |
srcDecimals* | integer | Source Token Decimals. (Can be omitted if Token Symbol is used in |
destToken* | string | Destination Token Address. Instead Token Symbol could be used for tokens listed in the |
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: |
network | string | Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114).
Default: |
otherExchangePrices | boolean | If provided, others object is filled in the response with price quotes from other exchanges (if available for comparison).
Default: |
includeDEXS | string | Comma Separated List of DEXs to include.
Supported DEXs:
Uniswap, Kyber, Bancor, AugustusRFQ, Oasis, Compound, Fulcrum, 0x, MakerDAO, Chai, Aave, Aave2, MultiPath, MegaPath, Curve, Curve3, Saddle, IronV2, BDai, idle, Weth, Beth, UniswapV2, Balancer, 0xRFQt, 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: |
excludeDEXS | string | Comma Separated List of DEXs to exclude. (from the list of DEXs mentioned above). |
includeContractMethods | 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: |
excludeContractMethods | string | Comma Separated List of Contract Methods to exclude without spaces. (from the list of contract methods mentioned above). |
userAddress | string | User's Wallet Address. |
route | string | Dash (-) separated list of tokens (addresses or symbols from |
partner | string | Partner string. |
partnerFeeBps | string | If provided it is used together with *Note: Fees have to be claimed from the Fee Claimer contract unless |
partnerAddress | string | Address that will be entitled to claim fees or surplus. *Note: Fees have to be claimed from the Fee Claimer contract unless |
slippage | integer | Allowed slippage percentage represented in basis points.
Eg: for 2.5% slippage, set the value to 2.5 * 100 = 250; for 10% = 1000. Slippage could be passed instead of |
destDecimals* | integer | Destination Token Decimals. (Can be omitted if Token Symbol is used in |
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
**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
**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
**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
**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 |
ignoreBadUsdPrice | boolean | If tokens USD prices are not available, |
isSurplusToUser | boolean | Specify if user should receive surplus instead of partner.
Default: |
isDirectFeeTransfer | boolean | Specify if fees should be sent directly to the partner instead of registering them on FeeClaimer. Default: |
isCapSurplus | boolean | Allows for capping the surplus at 1% maximum. Default: |
takeSurplus | boolean | Allows to collect surplus. Works with Default: |
🧙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
Most common error messages
The following is a list of the most common error messages of the /swap
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.
Missing response from pricing API
- failed to get a response from pricing APICan not receive price route
- failed to receive price route from the pricing API response
Last updated