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

What is 0x Swap API?

The 0x API is a REST API that runs on HTTP. The 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.
📍 New to 0x Swap API? Watch this video on 🛠 Building Token Swaps with 0x API. It covers and overview of how the Swap API works, how to use it, and project ideas.

Why use 0x Swap API?

0x Swap API watches out for your users and is easy for developers.
  • By default, it has built-in user-protection features, including:
  • 0x collects limited trade surplus (read more here).
  • 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 certain 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.
  • Swap 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.
  • Swap API's Slippage Protection enables developers to surface more reliable quotes and consistently deliver the best executed price to users.
  • Swap API's Price Impact Protection calculates price impact estimates, and allows developers to easily notify users if insufficient liquidity may negatively affect the price.
  • 0x API's 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