Introduction
Easily embed crypto trading in your app with Swap API
Prefer to watch a video or see a code demo instead? Jump to 0x Videos or 0x Code Examples.
What is Swap API?
Swap API is a professional-grade DEX aggregation and smart order routing REST API that allows you to find the best price and easily submit the trade with just a few lines of code.
Swap API allows you to add crypto trading in your application with just a single API integration. It finds the best real-time price across 100+ liquidity sources, both public (AMMs) and private (professional market makers), across the supported chains.
Want to build a gasless trading app? Check out Gasless API instead.
Why use Swap API?
Swap API is designed to protect your users, streamline integration for developers, and unlock new revenue opportunities for your team.
- ⛓️ Multi-chain liquidity: Access deep liquidity across major networks. See supported networks.
- 🤑 Monetize your app: Earn revenue through every swap with built-in fee support.
- 🛡️ User protection: Our smart contracts reduce allowance risk by supporting modern standards like AllowanceHolder and Permit2 for safer token approvals.
- ↩️ Reliable execution: We offer some of the lowest revert rates in the industry.
- 💰 Exclusive RFQ liquidity: Access off-chain liquidity with 0 slippage for RFQ orders. Learn how RFQ works.
- 🚀 Developer-friendly: Easy to integrate and customizable to your use case. Find the best price to buy DAI with WETH with the following request:
Try it out
Run this curl request to see a live quote response for selling 100,000 WETH to buy DAI:
// Sell 100,000 WETH for DAI
// Taker address is vitalik.eth
// Replace "YOUR_API_KEY" with your actual API key from https://dashboard.0x.org/create-account
curl --request GET \
--url "https://api.0x.org/swap/allowance-holder/quote?sellAmount=100000000000000000000000&taker=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045&chainId=1&sellToken=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&buyToken=0x6b175474e89094c44da98b954eedeac495271d0f" \
--header "0x-api-key: YOUR_API_KEY" \
--header "0x-version: v2"
You will receive a response that looks like this:
Expand to see response
{
"allowanceTarget": "0x0000000000001ff3684f28c67538d4d072c22734",
"blockNumber": "23187566",
"buyAmount": "235932519449815263461168645",
"buyToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
"fees": {
"integratorFee": null,
"zeroExFee": {
"amount": "326467223589357163093426",
"token": "0x6b175474e89094c44da98b954eedeac495271d0f",
"type": "volume"
},
"gasFee": null
},
"issues": {
"allowance": {
"actual": "0",
"spender": "0x0000000000001ff3684f28c67538d4d072c22734"
},
"balance": {
"token": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"actual": "0",
"expected": "100000000000000000000000"
},
"simulationIncomplete": false,
"invalidSourcesPassed": []
},
"liquidityAvailable": true,
"minBuyAmount": "233569649951068991418492945",
"route": {
"fills": [
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"source": "Uniswap_V3",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"source": "Uniswap_V3",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"source": "Curve",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"source": "Curve",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"source": "Uniswap_V4",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"source": "Uniswap_V2",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"source": "SushiSwap",
"proportionBps": "500"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"source": "RingSwap",
"proportionBps": "500"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"source": "Uniswap_V3",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"source": "Uniswap_V2",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"source": "SushiSwap",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Uniswap_V3",
"proportionBps": "499"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Uniswap_V3",
"proportionBps": "249"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Uniswap_V3",
"proportionBps": "499"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Curve",
"proportionBps": "249"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Uniswap_V4",
"proportionBps": "249"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Uniswap_V4",
"proportionBps": "756"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Uniswap_V2",
"proportionBps": "499"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Uniswap_V4",
"proportionBps": "249"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"source": "Uniswap_V3",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"source": "Uniswap_V3",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"source": "Uniswap_V3",
"proportionBps": "1251"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"source": "Uniswap_V4",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"source": "Uniswap_V2",
"proportionBps": "1000"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"source": "PancakeSwap_V3",
"proportionBps": "250"
},
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0xf939e0a03fb07f59a73314e73794be0e57ac1b4e",
"source": "Curve",
"proportionBps": "250"
},
{
"from": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"source": "Uniswap_V3",
"proportionBps": "174"
},
{
"from": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Uniswap_V3",
"proportionBps": "2036"
},
{
"from": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "0x_RFQ",
"proportionBps": "290"
},
{
"from": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"source": "Uniswap_V3",
"proportionBps": "104"
},
{
"from": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"source": "Curve",
"proportionBps": "2955"
},
{
"from": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"to": "0xf939e0a03fb07f59a73314e73794be0e57ac1b4e",
"source": "Curve",
"proportionBps": "366"
},
{
"from": "0xf939e0a03fb07f59a73314e73794be0e57ac1b4e",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"source": "Curve",
"proportionBps": "616"
},
{
"from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"to": "0x6b175474e89094c44da98b954eedeac495271d0f",
"source": "Maker_PSM",
"proportionBps": "6191"
}
],
"tokens": [
{
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"symbol": "WETH"
},
{
"address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
"symbol": "WBTC"
},
{
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"symbol": "USDT"
},
{
"address": "0xf939e0a03fb07f59a73314e73794be0e57ac1b4e",
"symbol": "crvUSD"
},
{
"address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"symbol": "USDC"
},
{
"address": "0x6b175474e89094c44da98b954eedeac495271d0f",
"symbol": "DAI"
}
]
},
"sellAmount": "100000000000000000000000",
"sellToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"tokenMetadata": {
"buyToken": {
"buyTaxBps": "0",
"sellTaxBps": "0"
},
"sellToken": {
"buyTaxBps": "0",
"sellTaxBps": "0"
}
},
"totalNetworkFee": "31754911939128290",
"transaction": {
"to": "0x0000000000001ff3684f28c67538d4d072c22734",
"data": "0x2213bc0b000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000152d02c7e14af6800000000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000003da41fff991f000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000c1344c185dcebc2587681100000000000000000000000000000000000000000000000000000000000000a0f7107a43f9382b57c6b0c4e70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000005400000000000000000000000000000000000000000000000000000000000000660000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000a600000000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000d600000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000013200000000000000000000000000000000000000000000000000000000000001440000000000000000000000000000000000000000000000000000000000000154000000000000000000000000000000000000000000000000000000000000016400000000000000000000000000000000000000000000000000000000000001760000000000000000000000000000000000000000000000000000000000000188000000000000000000000000000000000000000000000000000000000000019a00000000000000000000000000000000000000000000000000000000000001b600000000000000000000000000000000000000000000000000000000000001ca00000000000000000000000000000000000000000000000000000000000001e400000000000000000000000000000000000000000000000000000000000001f80000000000000000000000000000000000000000000000000000000000000212000000000000000000000000000000000000000000000000000000000000022200000000000000000000000000000000000000000000000000000000000002360000000000000000000000000000000000000000000000000000000000000250000000000000000000000000000000000000000000000000000000000000026200000000000000000000000000000000000000000000000000000000000002740000000000000000000000000000000000000000000000000000000000000286000000000000000000000000000000000000000000000000000000000000029a00000000000000000000000000000000000000000000000000000000000002b400000000000000000000000000000000000000000000000000000000000002c400000000000000000000000000000000000000000000000000000000000002d600000000000000000000000000000000000000000000000000000000000002f20000000000000000000000000000000000000000000000000000000000000304000000000000000000000000000000000000000000000000000000000000031600000000000000000000000000000000000000000000000000000000000003420000000000000000000000000000000000000000000000000000000000000354000000000000000000000000000000000000000000000000000000000000036e000000000000000000000000000000000000000000000000000000000000038800000000000000000000000000000000000000000000000000000000000003a200000000000000000000000000000000000000000000000000000000000003ae00000000000000000000000000000000000000000000000000000000000003b8000000000000000000000000000000000000000000000000000000000000000e4c1fb425e000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000152d02c7e14af680000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000068a6b8f100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f00000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000001f42260fac5e5542a773aa44fbcfedf7c193bc2c59900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000bb82260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000107000000000000000000000000f5f5b97624542d72a9e06f04804bf81baa15e2b4000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a45b41b908000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000010e000000000000000000000000d51a44d3fae010294c616388b506acda1bfaae46000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a45b41b908000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000115000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000242e1a7d4d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164af72634f000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000ffffffffffffffc50000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000342710012260fac5e5542a773aa44fbcfedf7c193bc2c599000bb800003c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4103b48be000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000011d000000000000000000000000bb2b8038a1640196fbe3e38816f3e67cba72d9400000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4103b48be000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000024c000000000000000000000000ceff51756c56ceffca006cd410b03ffc46dd3a580000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000027100000000000000000000000039d1d8fcc5e6eeaf567bce4e29b94fec956d3519000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010438ed173900000000000000000000000000000000000000000000010f0cf064dd59200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f0000000000000000000000000000000000000000000000000000000068a6b8f10000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a250cc729bb3323e7933022a67b52200fe3547670000000000000000000000002078f336fdd260f708bec4a20c82b063274e1b23000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000014d00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000bb86b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4103b48be000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000158000000000000000000000000a478c2975ab1ea89e8196811f51a7b7ade33eb110000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4103b48be000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000165000000000000000000000000c3d03e4f041fd4cd388c549ee2a29a9e5075882f0000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f00000000000000000000000000000000000000000000000000000000000002e400000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000064a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000034100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000001c60000000000000000000000007f86bf177dd4f3494b841a37e810a34dd56c829b000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a45b41b908000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000001dc000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000242e1a7d4d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164af72634f000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000ffffffffffffffc5000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034271001a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000064000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000005db000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000242e1a7d4d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164af72634f000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000ffffffffffffffc5000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034271001a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f400000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4103b48be000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000498000000000000000000000000b4e16d0168e52d35cacd2c6185b44281ec28c9dc0000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000029a000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000242e1a7d4d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164af72634f000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000ffffffffffffffc5000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034271001a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000bb800003c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f00000000000000000000000000000000000000000000000000000000000002ca00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000001f4dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000030100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000064dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000104600000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000bb8dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000594000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000242e1a7d4d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164af72634f000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000ffffffffffffffc5000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034271001dac17f958d2ee523a2206206994597c13d831ec70001f400000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4103b48be000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000001a0a0000000000000000000000000d4a11d5eeaac28ec3f61d100daf4d40471f18520000000000000000000000000000000000000000000000000000000000001e0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000138800000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2010001f4dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018438c9c147000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000027100000000000000000000000004ebdf703948ddcea3b11f675b4d1fba9d2414a14000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a45b41b90800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f00000000000000000000000000000000000000000000000000000000000002b900000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c2260fac5e5542a773aa44fbcfedf7c193bc2c59900000bb8dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000222e00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c2260fac5e5542a773aa44fbcfedf7c193bc2c59900000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028438c9c1470000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000000002710000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff000000000000000000000000000000000000000000000000000000000000018400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a4dac748d4000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000069f4291b0e9000000000000000000000000000000000000000000000000000000017f5b5aff00000000000000000000000051c72848c68a965f66fa7a88855f9f7784502a7f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000068a6b801000000000000000100000000000000000000000068a6b7c50000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001cb416fcb2068d086b18f0705f0ee578cb8f35159a21b838dc210b1003aa4392340ffb4c784790f51ebea260d90cc8cf474e744e886af46e185225d1c1d727bc130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e48d68a156000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cdac17f958d2ee523a2206206994597c13d831ec7000000646b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016438c9c147000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000022c1000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000843df0212400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016438c9c147000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000000000000000000000000000000000000000002710000000000000000000000000390f3595bca2df7d23783dfd126427cceb997bf4000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000843df0212400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016438c9c147000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e00000000000000000000000000000000000000000000000000000000000027100000000000000000000000004dece678ceceb27446b35c672dc7d61f30bad69e000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000843df02124000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084bfda5292000000000000000000000000df31a70a21a1931e02033dbba7deace6c45cfd0f000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064c876d21d000000000000000000000000f5c4f3dc02c3fb9279495a8fef7b0741da9561570000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000c373b53852bcbc86feac1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012438c9c1470000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000ad01c20d5886137e056775af56915de824c8fce50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gas": "87021770",
"gasPrice": "364907677",
"value": "0"
},
"zid": "0xf7107a43f9382b57c6b0c4e7"
}
This is a valid unsigned Ethereum transaction that can be signed and submitted directly to a node to complete the swap. Read more about the parameters here.
How does it work?
Swap API is a professional-grade DEX aggregation and smart order routing API. Using the API, developers can easily and reliably tap into aggregated multi-chain DEX liquidity. Swap API finds the best executed price across 150+ liquidity sources, both public (AMMs) and private (professional market makers), across a growing number of blockchains
Below is a high-level diagram showing how Swap API works under the hood:
- Retail Trader Requests a quote
- Swap API simultaneously (a) retrieves quote from AMM and (b) requests quotes from Market Makers
- Market Makers responds with signed quote at their discretion
- Swap API aggregates the quotes it has received and compares the prices. It returns the best price to the Retail Trader.
- If the Retail Trader likes the quote, the Retail Trader signs the order. Swap API sends the signed order to the blockchain to be settled by the 0x Protocol.
For more details about how 0x orders are executed, check out How does 0x work?
Under the hood, Swap API performs a series of 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.
- The response returned by Swap API is a valid unsigned Ethereum transaction that can be signed and submitted directly to an Ethereum node. Easily execute using the transaction using the web3 library of your choice.
Supported Chains
Swap and Gasless v2 APIs are currently supported on the following chains. Select the chain in your request by providing the corresponding chainId
request parameter. To request support for a new chain, please submit a request here.
Chain | Chain ID | Swap API | Gasless API |
---|---|---|---|
Ethereum (Mainnet) | 1 | ✅ | ✅ |
Arbitrum | 42161 | ✅ | ✅ |
Avalanche | 43114 | ✅ | ✅ |
Base | 8453 | ✅ | ✅ |
Berachain | 80094 | ✅ | |
Blast | 81457 | ✅ | ✅ |
BSC | 56 | ✅ | ✅ |
Ink | 57073 | ✅ | |
Linea | 59144 | ✅ | |
Mantle | 5000 | ✅ | ✅ |
Mode | 34443 | ✅ | ✅ |
Monad | 10143 | ✅ | |
Optimism | 10 | ✅ | ✅ |
Polygon | 137 | ✅ | ✅ |
Scroll | 534352 | ✅ | ✅ |
Unichain | 130 | ✅ | |
World Chain | 480 | ✅ |
Get Started
To create an account, and get your live API keys to access 0x APIs, visit the 0x Dashboard.
Now that you're familiar with what Swap API offers, read Get started with Swap API to get started or choose one of the resources below.