Swap API

Swap API

Powerful trades with a few lines of code

We’ve been building world-class Swaps since 2017 so you don’t have to. Access the most efficient liquidity for web3 tokens through a single API.

Get started
Swap API

Your gateway into web3

Best prices, all-in

Keep users in your app by offering the best trading experience directly inside your product. Access to 7+ million tokens at the best prices all-in, with the lowest revert rate in the industry.

Unlock revenue

Monetization features that help you sustainably grow your business, with multiple fee collection options. Control your balance sheet by collecting fees in either the buy or sell token.

Security & reliability

Enterprise grade services you can build your business on, with 99.99% uptime. Built with security first and multiple third party audits to ensure there are no vulnerabilities to exploit.

Advanced routing for any trade

0x Argon Router’s multihop and multiplex routing delivers the best prices and optimal trading path for users.

Uniswap V2

0x RFQ

Balancer v2

Sushiswap v3

Dodo

Curve

Lido

Best in class performance

Battle-tested since 2017, 0x is the trusted leader in the decentralized exchange infrastructure.

99.82%

Historical Uptime

5%

Revert rates
Lowest in Defi

<500ms

Median response time

500+

Integrators

Built for serious onchain apps

10 EVM Networks:

Available on the largest chains, including Ethereum, Base, Arbitrum, BNB Chain, Polygon and more.

Deepest Coverage:

Access 7M+ tokens with unrivaled liquidity from 130+ exchanges, including tokens with buy/sell taxes.

Slippage & MEV Protection:

Designed to minimize the impact of sandwich attacks and MEV. Users save an average of ~50-80% on slippage.

Exclusive RFQ Liquidity:

Unlock top-tier liquidity coverage from sophisticated market makers. 0x RFQ outperforms AMMs on price 46% of the time where available.

Actionable User Insights:

Understand your user trading behavior with in-depth charts and data from onchain trades with 0x Trade Analytics.

Monetization Controls:

Unlock new revenue streams with multiple options. Choose which tokens to collect fees in.

Lower Risk Profile:

Leverage Permit2 to bolster your apps defensibility and lower your risk profile for the unthinkable.

Address Screening:

Built-in regulatory and legal compliance. Avoid hefty fees with no additional integration or cost.

Reduce Errors with Smart Validation:

Reliable quotes with accurate gas estimates, every time.

Buy/Sell Tax Support:

Keep up with trends, keep up with user demands.

Simplified Error Handling:

Error messages designed for humans. Solving the most tedious part of the developer experience with description vs cryptic error codes.

Dedicated Support:

Get help from an expert in 30 min or less directly through the 0x Dashboard.

Integrate in 5 minutes or less

Embed crypto trading in your app with just a few lines of code.

Play


const main = async () => {

	 const sellAmount = parseUnits("1000", await usdc.read.decimals());

  	// fetch quote
  	const quoteParams = new URLSearchParams({
  		chainId: client.chain.id.toString(),
    	sellToken: usdc.address,
    	buyToken: weth.address,
    	sellAmount: sellAmount.toString(),
      taker: client.account.address,
    });

  const quoteResponse = await fetch(
    "https://api.0x.org/swap/permit2/quote?" + quoteParams.toString(),
    {
      headers,
    }
  );

  const quote = await quoteResponse.json();
  console.log("Quote to swap 1000 USDC for WETH: ", quote);

}
main();

Play


const main = async () => {

	 const sellAmount = parseUnits("1000", await usdc.read.decimals());

  	// fetch quote
  	const quoteParams = new URLSearchParams({
  		chainId: client.chain.id.toString(),
    	sellToken: usdc.address,
    	buyToken: weth.address,
    	sellAmount: sellAmount.toString(),
      taker: client.account.address,
    });

  const quoteResponse = await fetch(
    "http://api.0x.org/gasless/quote?" + quoteParams.toString(),
    {
      headers,
    }
  );

  const quote = await quoteResponse.json();
  console.log("Quote to swap 1000 USDC for WETH: ", quote);

}
main();

Developer Guides

Tap into a decade of onchain expertise

Developer Guides

Fundamentals: Smart Contract Wallets

Compliance made easy with 0x Address Screening

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

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

Take control of your balance sheet with 0x v2

0x v2 bug bounty program

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

Eliminate allowance risk with Permit2

Introducing 0x's next-gen pricing engine

0x Dev Digest: May 2024

Frame spotlight: Paycaster

Frame spotlight: Airstack

Power up your Farcaster Frames with 0x swaps

0x Dev Digest: April 2024

Introducing 0x Trade Analytics

Coinbase Case Study

Introducing gasless swaps and approvals with Gasless API

Bitcoin ETFs have arrived

Building in the open: 0x pricing update

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

0x Dev Digest: October 2023

Monetize crypto trading in your app with Swap API

0x Dev Digest: September 2023

A comprehensive analysis of RFQ performance

Unlock optimal trades in Swap API with 0x RFQ liquidity

0x Dev Digest: August 2023

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

0x Swap API is now live on Base

Introducing paid plans for Swap API

Decreasing Frictions in DeFi hackathon recap

0x's pricing principles

0x Dev Digest: June 2023

App spotlight: tastycrypto

App spotlight: 31Third

0x 101: Intro to gasless API

Inspiration for building with Swap API

0x Dev Digest: May 2023

Fundamentals: What are gas fees?

Decreasing Frictions in DeFi Hackathon

Swap API liquidity management

0x 101: Getting started with Swap API

0x 101: Intro to Swap API

0x 101: Intro to 0x Orders

0x 101: Intro to 0x Protocol

A new home for 0x Protocol

Say hi to the new 0x

0x Year in Review 2022

0x Swap API expands to Arbitrum

Managed liquidity

0x Smart Order Routing

App spotlight: Taho

Fundamentals: What is a Layer 2 chain?

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

Fundamentals: What is price impact?

Fundamentals: What is slippage?

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

Fundamentals: What is market making?

Fundamentals: What is a DEX aggregator?

Fundamentals: What is liquidity?

Fundamentals: What is a decentralized exchange (DEX)?

0x at ETHDenver 2023

The 0x Mission and Values

Announcing support for new testnets

0x Swap API expands to Binance Smart Chain

Scaling DeFi — Layer One

Introducing Slippage Protection

San Francisco Blockchain Week 2022 Recap

0x Swap API adds new liquidity sources

Review of slippage performance

Phuture case study

Measuring the impact of hidden DEX costs

Market making in DeFi

Introducing 0x Labs

Introducing 0x Explorer

Growing DeFi with professional market makers

0x 101: How to Access 0x Data

GameStop chooses 0x Swap API

Build on Base with 0x

A comprehensive analysis on DEX liquidity aggregators’ performance

Announcing 0x Swap API v1

Access all DEX liquidity through 0x Swap API

Announcing the 0xpo Summit 2022

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

Update to our Privacy Policy

Price Impact Protection has arrived

0x Limit Orders Go Multi-Chain

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

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

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

App spotlight: Zerion

App spotlight: Matcha

App spotlight: DexGuru

App spotlight: DEXTools

App spotlight: DODO

App spotlight: DappRadar

App spotlight: DeFi Saver

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

0x Swap API now supports 0x Protocol v4

0x Swap API is now available on Fantom

0x Swap API is now live on Optimism