0x 101: Intro to Swap API

With Swap API, you can easily power crypto trading in your application with a single integration that unlocks thousands of tokens. In this guide, we''ll take a deeper look at what Swap API is and how you can leverage it to access deep liquidity without the infrastructure overhead.

May 9, 2023

Learn & Build

Swap API is your gateway to unrivaled liquidity. With Swap API, you can easily power crypto trading in your application with a single integration that unlocks thousands of tokens.

In this guide, we''ll take a deeper look at what Swap API is and how you can leverage it to access deep liquidity without the infrastructure overhead.

What is Swap API?

Building in Web3 has become increasingly difficult as the number of ecosystems, DEX protocols, and tokens has grown. And in DeFi, liquidity is fragmented across dozens of sources, making it difficult for users to find the best prices.

Swap API solves this by fetching available quotes from across the liquidity supply to help users quickly find the best price for a given trade. It aggregates liquidity from 100+ exchanges, including the most popular AMMs and private market makers, across the most popular chains - allowing you to easily tap into the deepest liquidity with one simple integration.

Swap API is a REST API that runs on HTTP. We built Swap API to make it easy for developers to leverage the underlying trade settlement of 0x Protocol, a set of smart contracts that make up the base layer of the 0x tech stack, and integrate swap functionality into their apps.

How does Swap API work?

Think of how Google Flights aggregates flight prices for a certain route and time to help you find the best price.

Under the hood, Swap API works similarly by querying prices from dozens of decentralized exchanges (DEXes), such as Uniswap, Aave, and Sushiwap, and professional market makers across the most popular blockchains, including Ethereum, Polygon, and Arbitrum, and aggregating the liquidity from the queried sources to help users quickly find the best price for a given trade.

Swap API’s proprietary smart order routing algorithm then splits up a user’s transaction across different sources to maximize the overall return on the trade by analyzing gas costs, available liquidity, execution quality, and price impact in real-time.

For example, the best price to sell 1,500 DAI for ETH may be 50% through Bancor, 25% through Uniswap, and 25% through Sushiswap. Swap API’s smart order routing logic automatically calculates this and packages it into a single quote that’s ready to be executed using the Web3 library of your choice. Whether you prefer web3.js or ether.js, or something else, you are in control.

Why use Swap API?

Swap API provides access to deep liquidity without the infrastructure overhead.

Similar to managing nodes or other layers of infrastructure, managing liquidity sources is a vital piece of the infrastructure stack. Missteps in sourcing liquidity can result in poor experiences for users, including uncompetitive pricing, lack of token coverage, and increased slippage. With Swap API, we manage the overhead and allow you to focus on building what matters: your product. 

Unlimited crypto assets: One integration with 0x unlocks thousands of tokens on the most popular blockchains and aggregated liquidity from 100+ AMMs and market makers.

Slippage and MEV protection: When trading on DEXes, slippage can cause the price to shift before the trade actually executes. Swap API is designed to minimize the impact of sandwich attacks and MEV. When Slippage Protection is enabled, users save an average of 50-80% on slippage.

Price Impact Protection: Similar to slippage, price impact can occur in between a trader placing a trade and its actual execution. Price Impact Protection is an optional feature that, when enabled, protects users from suffering significant losses by trading illiquid tokens. 

Low revert rates: Despite the complexity of routing orders through multiple DEXes and market makers, Swap API’s robust infrastructure enables it to have a 4x lower revert rate than competitors.

Exclusive RFQ liquidity: We work with Professional Market Makers to provide exclusive RFQ liquidity. This liquidity is competitive with AMMs, and comes with additional benefits, including zero slippage and guaranteed MEV protection.

Monetization options: Swap API offers Web3 teams low-friction ways to monetize their products. Leverage Swap API to unlock new revenue streams by easily tapping into affiliate fee and trade surplus features.

And best of all, it’s easy to use! With Swap API, you can enable crypto trading in your app with just a few lines of code. For example, you can easily find the best price to buy DAI with WETH with this simple request.

What can you build with Swap API?

Swap API is extremely versatile. It has become the go-to endpoint for DEX liquidity for leading teams across the Web3 ecosystem. Since launch, over $125 billion in tokenized value has been traded across 50 million transactions with Swap API. Here are some example use cases.

Centralized exchanges act as intermediaries between buyers and sellers, facilitating the trading of cryptocurrencies. Swap API can be integrated by centralized exchanges to expand the trading options available to users. Coinbase leverages Swap API to power DEX trading.

Fintechs can utilize Swap API to enable seamless cryptocurrency transactions for their users, expanding the offerings available within their platforms.

Self-custody wallets allow users to store, transfer, and swap tokens. Wallets can integrate Swap API in order to offer the ability to swap tokens at the best prices directly within the UI. Swaps in Metamask, Phantom, and Brave Wallet are all powered by 0x.

Decentralized exchanges allow users to exchange one cryptocurrency token for another without intermediaries. Leading DEXes, such as Matcha, Cowswap, and dYdX, use Swap API to access deep liquidity and get users the best price.

Portfolio management apps provide a convenient way to build and manage a portfolio of tokenized assets. These apps often offer additional features such as direct token swaps, automatic liquidation protection, liquidity mining, and yield farming. Top portfolio managers, including Zapper, Zerion, and DeFi Saver, rely on 0x.

DeFi investment apps offer their users various active and passive investment strategies, such as creating and trading baskets of assets, earning optimized lending yields, and social trading. Learn how Phuture utilizes Swap API to power all of its on-chain index funds and improve returns for users.

Ready to get started?

Check out our guide below to get started building with Swap API.


Contents

Subscribe to newsletter

By submitting you're confirming that you agree with our Terms and Conditions.
Yay! You’re signed up.
Oops! Something went wrong, but it's not your fault.

Up next

Unlock powerful onchain insights with 0x Trade Analytics API

Nov 5, 2024

Fundamentals: Smart Contract Wallets

Oct 15, 2024

Compliance made easy with 0x Address Screening

Sep 26, 2024

0x's next-gen pricing engine is now live

Sep 25, 2024

Introducing state-of-the-art Buy/Sell Tax support

Sep 4, 2024

Take control of your balance sheet with 0x v2

Aug 15, 2024

0x v2 bug bounty program

Jul 30, 2024

What does the "best price" in DeFi really mean?

Jul 23, 2024

Eliminate allowance risk with Permit2

Jul 17, 2024

Introducing 0x's next-gen pricing engine

Jul 15, 2024

0x Dev Digest: May 2024

May 31, 2024

Frame spotlight: Paycaster

May 21, 2024

Frame spotlight: Airstack

May 9, 2024

Power up your Farcaster Frames with 0x swaps

May 2, 2024

0x Dev Digest: April 2024

Apr 30, 2024

Introducing 0x Trade Analytics

Mar 12, 2024

Coinbase Case Study

Jan 30, 2024

Introducing gasless swaps and approvals with Gasless API

Jan 22, 2024

Bitcoin ETFs have arrived

Jan 12, 2024

Building in the open: 0x pricing update

Dec 11, 2023

Matcha leverages Gasless API to bring users the most frictionless trading experience in DeFi

Nov 30, 2023

0x Dev Digest: October 2023

Nov 2, 2023

Monetize crypto trading in your app with Swap API

Oct 26, 2023

0x Dev Digest: September 2023

Oct 3, 2023

A comprehensive analysis of RFQ performance

Sep 26, 2023

Unlock optimal trades in Swap API with 0x RFQ liquidity

Sep 20, 2023

0x Dev Digest: August 2023

Aug 31, 2023

Portal launches swaps in its white label MPC wallet powered by 0x

Aug 16, 2023

0x Swap API is now live on Base

Aug 9, 2023

Introducing paid plans for Swap API

Jul 24, 2023

Decreasing Frictions in DeFi hackathon recap

Jul 12, 2023

0x's pricing principles

Jul 3, 2023

0x Dev Digest: June 2023

Jun 30, 2023

App spotlight: tastycrypto

Jun 27, 2023

App spotlight: 31Third

Jun 22, 2023

0x 101: Intro to gasless API

Jun 13, 2023

Inspiration for building with Swap API

Jun 8, 2023

0x Dev Digest: May 2023

May 31, 2023

Fundamentals: What are gas fees?

May 25, 2023

Decreasing Frictions in DeFi Hackathon

May 12, 2023

Swap API liquidity management

May 18, 2023

0x 101: Getting started with Swap API

May 16, 2023

0x 101: Intro to 0x Orders

May 4, 2023

0x 101: Intro to 0x Protocol

Apr 27, 2023

A new home for 0x Protocol

Apr 24, 2023

Say hi to the new 0x

Apr 20, 2023

0x Year in Review 2022

Jan 5, 2023

0x Swap API expands to Arbitrum

Sep 22, 2022

Managed liquidity

Apr 23, 2020

0x Smart Order Routing

May 19, 2020

App spotlight: Taho

Mar 8, 2022

Fundamentals: What is a Layer 2 chain?

Apr 19, 2023

Fundamentals: What is the difference between quoted, executed, and adjusted prices?

Apr 19, 2023

Fundamentals: What is price impact?

Apr 19, 2023

Fundamentals: What is slippage?

Apr 19, 2023

Fundamentals: What is an automated market maker (AMM)?

Apr 19, 2023

Fundamentals: What is market making?

Apr 19, 2023

Fundamentals: What is a DEX aggregator?

Apr 19, 2023

Fundamentals: What is liquidity?

Apr 19, 2023

Fundamentals: What is a decentralized exchange (DEX)?

Apr 19, 2023

0x at ETHDenver 2023

Mar 21, 2023

The 0x Mission and Values

Jun 7, 2018

Announcing support for new testnets

Aug 10, 2022

0x Swap API expands to Binance Smart Chain

Mar 17, 2021

Scaling DeFi — Layer One

Sep 1, 2021

Introducing Slippage Protection

Jul 14, 2022

San Francisco Blockchain Week 2022 Recap

Nov 21, 2022

0x Swap API adds new liquidity sources

Jul 11, 2022

Review of slippage performance

Sep 14, 2022

Phuture case study

Oct 20, 2022

Measuring the impact of hidden DEX costs

Apr 14, 2022

Market making in DeFi

Aug 12, 2021

Introducing 0x Labs

Jun 22, 2020

Introducing 0x Explorer

Oct 26, 2022

Growing DeFi with professional market makers

Aug 26, 2020

0x 101: How to Access 0x Data

Apr 25, 2023

GameStop chooses 0x Swap API

Jul 8, 2022

Build on Base with 0x

Feb 23, 2023

A comprehensive analysis on DEX liquidity aggregators’ performance

Oct 1, 2020

Announcing 0x Swap API v1

Oct 1, 2020

Access all DEX liquidity through 0x Swap API

Jan 28, 2020

Announcing the 0xpo Summit 2022

Aug 24, 2022

0x Protocol, a preview of what’s to come

Mar 16, 2023

Update to our Privacy Policy

Mar 14, 2023

Price Impact Protection has arrived

Dec 14, 2022

0x Limit Orders Go Multi-Chain

Dec 23, 2021

0x Labs raises $70M Series B led by Greylock to continue expanding Web3’s core exchange infrastructure

Apr 26, 2022

0x launches Tx Relay API in beta, with Robinhood Wallet as first partner

Mar 1, 2023

0x Labs raises $15M Series A to bring decentralized exchange markets to a global audience

Feb 5, 2021

App spotlight: Zerion

Jun 22, 2022

App spotlight: Matcha

Nov 24, 2021

App spotlight: DexGuru

Jun 17, 2021

App spotlight: DEXTools

Sep 23, 2021

App spotlight: DODO

Aug 10, 2021

App spotlight: DappRadar

Dec 16, 2021

App spotlight: DeFi Saver

Jul 20, 2021

0x + Brave partner to make crypto and DeFi more accessible to everyone

Jul 7, 2021

0x Swap API now supports 0x Protocol v4

Mar 1, 2021

0x Swap API is now available on Fantom

Oct 26, 2021

0x Swap API is now live on Optimism

Jan 11, 2022