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 that you will use to interact with the ParaSwap API. Let's take an example that you want to swap 10 ETH to DAI.
First, you should call
/prices endpoint (detailed documentation here) using an HTTP query like
GET https://apiv5.paraswap.io/prices/?srcToken=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&destToken=0x6b175474e89094c44da98b954eedeac495271d0f&amount=10000000000000000000&srcDecimals=18&destDecimals=18&side=SELL&network=1This will return the optimal prices using ParaSwap's Hopper Algorithm.
If you are satisfied with the price then 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://www.npmjs.com/package/paraswap.
If you want to do some swaps you can directly use our UI.