*** title: Onchain Swaps for Exchanges description: >- Learn how centralized exchanges and institutions can integrate onchain trading using Swap API. --------------- Crypto has scaled from a handful of listed assets to millions of onchain tokens, with thousands more launching every day. Traditional CEX listing processes can't keep pace — by the time a token clears compliance review, it may already be irrelevant. Meanwhile, DEX volume has grown from around \$600 million in Jan 2020 to over \$500B today, and the DEX-to-CEX volume ratio continues to climb. For exchanges and institutions, this creates a clear strategic risk: users who want access to long-tail tokens will leave your platform to trade elsewhere. **The solution is to bring onchain markets into your existing product.** Swap API lets you embed DEX trading directly into your exchange app — so users can access millions of tokens without ever leaving your platform. ![DEX to CEX volume](https://files.buildwithfern.com/0x.docs.buildwithfern.com/34664254af6dd03e5c34952f7ed3e4486939a85e08f74b996e8546eb4da946ea/docs/assets/img/0x-swap-api/dex-to-cex-volume.png) ### Proven in Production Exchanges use 0x to power DEX trading directly inside their main product, giving users access to millions of onchain tokens while preserving a familiar, professional trading experience. [Share the Coinbase case study with your team →](https://0x.org/case-studies/coinbase/exchange/) ### Why Exchanges Choose Swap API | Challenge | How Swap API Solves It | | ---------------------- | ---------------------------------------------------------------------------- | | Limited token coverage | Instant access to millions of onchain tokens across supported chains | | Fragmented liquidity | Aggregates 150+ sources including AMMs and professional market makers | | User churn to DEXs | Embedded DEX trading keeps users in your app | | Execution quality | Advanced routing, sub-250ms response times, and all-in pricing | | Compliance risk | Surface liquidity and risk signals (slippage, volatility, suspicious tokens) | ### Architecture Considerations for Exchanges Unlike a retail wallet integration, exchanges have additional requirements to account for when implementing onchain swaps: * **Custody model**: Swap API works with both custodial and non-custodial flows. For custodial exchanges, the `taker` address will typically be a hot wallet or smart contract you control on behalf of users. Ensure your allowance and signing flows account for this. * **Balance pre-checks**: Before showing a swap UI to users, use the `/price` endpoint to validate liquidity is available and surface any balance or allowance issues from the `issues` field in the response. * **Risk signals**: The `route`, `minBuyAmount`, and fee breakdown fields in the response give you the data you need to show users transparent, trustworthy pricing — critical for professional trading contexts. * **Chain expansion**: Swap API supports multiple chains with minimal code changes. Design your integration to accept `chainId` as a parameter from day one. *** ## About Swap API Swap API is a DEX aggregation and smart order routing REST API that finds the best price for crypto trades. With one API integration, you can easily add trading to your app. Swap API aggregates liquidity from 150+ sources, including AMMs and professional market makers, across the [supported chains](/docs/introduction/supported-chains). ![Swap API UI](https://files.buildwithfern.com/0x.docs.buildwithfern.com/fcd0acfc26bda98f67d639e66e85a7d59c2418fbb42bb247dad6f4d917509618/docs/assets/img/0x-swap-api/swap-api-ui.png) The API handles three key tasks: * Queries ERC20 prices from decentralized exchanges and market makers * Aggregates liquidity for the best possible price * Returns a trade format executable via your preferred web3 library ## What You Will Learn This guide will cover the core steps to using Swap API, specifically using the [Swap AllowanceHolder](/api-reference/openapi-json/swap/allowanceholder-getprice) endpoint. {" "} Learn about the [difference between AllowanceHolder and Permit2 in Swap API](/docs/introduction/faq#allowanceholder-and-permit2){" "} ## Playground Try this code example directly in your browser — no installation needed!