API v5
Introduction to ParaSwap API version 5
Last updated
Introduction to ParaSwap API version 5
Last updated
ParaSwap V5 has been released! See what's new here: https://twitter.com/paraswap/status/1433045723298291714
ParaSwap's goal is to deliver the best market prices by aggregating over multiple decentralized exchanges, market makers, and lending protocols.
ParaSwap API allows users to fetch optimal prices to swap from one token to another and then build transaction data that can be used to execute transactions on-chain. Currently, ParaSwap only supports EVM-based networks (Ethereum, BSC, Polygon, etc) and tokens following ERC20 standard.
Before you get deeper into the docs, here is a quick overview of the general flow you will use to interact with the ParaSwap API. Let's take the example of you wanting to swap 10 ETH to DAI.
First, you should call /prices
endpoint (detailed documentation here) using an HTTP query like GET https://api.paraswap.io/prices/?srcToken=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&destToken=0x6b175474e89094c44da98b954eedeac495271d0f&amount=10000000000000000000&srcDecimals=18&destDecimals=18&side=SELL&network=1&version=5
. This will return the optimal prices using ParaSwap's Hopper Algorithm
If you are satisfied with the price, you can call the /transactions
endpoint (detailed documentation here). This will return a transaction object.
You should then give the appropriate allowance to the tokenTransferProxy
for the source token. You can find the address of tokenTransferProxy
in the payload returned in the price endpoint. You can skip this step if a high enough allowance was already given.
You can finally use this transaction data to execute the swaps on-chain by sending it to the provider.
Check out the following pages to understand the ParaSwap v5 API. To try out all API endpoints, visit the Open-API documentation of ParaSwap v5.
Developers can also use our JS/TS SDK for web and Node.js integrations https://github.com/paraswap/paraswap-sdk
If you want to do some swaps, you can directly use our UI.
SELL:
simpleSwap
multiSwap
megaSwap
swapOnUniswapV2Fork
directUniV3Swap
directCurveV1Swap
directCurveV2Swap
directBalancerV2GivenInSwap
BUY:
simpleBuy
buy
buyOnUniswapV2Fork
directUniV3Buy
directBalancerV2GivenOutSwap