An introduction to how the 0x API swap endpoint works and the resources included this section
/swapendpoint aggregates liquidity from across the DEX ecosystem and easily surfaces the best price for ERC20 assets. The endpoint aggregates liquidity from both on-chain and off-chain liquidity networks.
The 0x API watches out for your users and is easy for developers.
- 0x collects 0% of positive slippage. In cases of positive slippage, the 0x protocol returns that difference back to the user.
- It is easy-to-use! For example, you can easily find the best price to buy DAI with WETH with this request
The response that is returned back is a valid unsigned Ethereum transaction that can be submitted directly to a node to complete the swap.
Under the hood, the API performs three tasks:
- Queries prices from multiple DEXs and market makers and aggregates the liquidity from the queried sources to provide the best price possible. Think of how Google flights aggregates flight prices for a certain time and date to help you find the best price,
/swapsimilarly helps you find the best price across DeFi liquidity sources.
- API responses are returned in a format that can be easily executed using the Web3 library of your choice
0x API's smart order routing algorithm helps users get the best price by splitting the swap across different DEXes.
This section contains the following docs and guides