0x Documentation


An introduction to how the 0x API swap endpoint works and the resources included this section

What is the 0x API swap Endpoint?

0x API’s /swap endpoint 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.

Why use the 0x API swap Endpoint?

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.
  • By default, it offers Slippage Protection which protects users against MEV-attacks
  • 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.

How does it work?

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, /swap similarly helps you find the best price across DeFi liquidity sources.
  • 0x API’s smart order routing algorithm splits up your transaction across different sources to maximize the overall return on your swap. Read more about smart order routing here.
  • 0x API's Slippage Protection enables developers to surface more reliable quotes and consistently deliver the best executed price to users.
  • API responses are returned in a format that can be easily executed using the Web3 library of your choice
This API is intended for public use. If you are an integrator who needs access higher rate limits, please fill out the 0x API Taker Integration Request Form.
0x API's smart order routing algorithm helps users get the best price by splitting the swap across different DEXes.

Get Started

This section contains the following docs and guides

API References

Advanced Topics