ParaSwap API v5
Introduction to ParaSwap API version 5
Live example of ParaSwap aggregation algorithm
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
/pricesendpoint (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=1. This will return the optimal prices using ParaSwap's Hopper Algorithm.
- You should then give the appropriate allowance to the
tokenTransferProxyfor the source token. You can find the address of
tokenTransferProxyin 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.
If you want to do some swaps, you can directly use our UI.