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.
Last updated
The /swap endpoint allows you to make one API call to get both the priceRoute object as well as the Transaction Object.
Last updated
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
https://api.paraswap.io/swap
This endpoint gets the optimal price and price route required to swap from one token to another.
Name | Type | Description |
---|---|---|
🧙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
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 API
Can not receive price route
- failed to receive price route from the pricing API response
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.
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: UniswapV3,0x
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: simpleSwap,multiSwap
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 /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.
partnerFeeBps
string
If provided it is used together with partnerAddress
. Should be in basis points percentage. Look at slippage
parameter description for understanding better. Eg: 200
(for 2% fee percent)
*Note: Fees have to be claimed from the Fee Claimer contract unless isSurplusToUser
or isDirectFeeTransfer
are used
partnerAddress
string
Address that will be entitled to claim fees or surplus.
*Note: Fees have to be claimed from the Fee Claimer contract unless isSurplusToUser
or isDirectFeeTransfer
are used
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 destAmount
when side=SELL or srcAmount
when side=BUY.
Min: 0; Max: 10000
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
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
isSurplusToUser
boolean
Specify if user should receive surplus instead of partner.
Default: false
isDirectFeeTransfer
boolean
Specify if fees should be sent directly to the partner instead of registering them on FeeClaimer.
Default: false
isCapSurplus
boolean
Allows for capping the surplus at 1% maximum.
Default: true
takeSurplus
boolean
Allows to collect surplus. Works with partnerAddress
Default: false