Matcha Swap or 0x Swap API for In-App Swaps: A Checklist
Matcha swap or 0x Swap API for an in-app token swap comes down to your product: link to Matcha for incidental swaps, but integrate the API when users must stay in your app or you want an integrator fee.
Should you link to Matcha or integrate 0x?
Link out when a swap is useful but peripheral to your product. Matcha is a decentralized exchange aggregator where users can exchange tokens through routes across liquidity sources. Linking avoids building a swap interface, but users leave your app and the link gives you no integrator fee. If swaps drive retention or revenue, I would integrate the API and take responsibility for the quoting and transaction flow.
Both choices use 0x routing. The API gives you control over the in-app experience and fee settings in exchange for building the wallet, approval, quote and error states yourself. Wallet type matters: use AllowanceHolder for multisigs and smart-contract wallets that cannot easily produce the off-chain Permit2 signature. Reserve Permit2 for EOAs when its granular or time-limited approvals justify the extra signature.
The Matcha token exchange is the direct route for a product whose users only occasionally need to trade. Use Matcha swap to let them swap tokens without building that flow into your app.
What must you prepare before shipping the API?
A working 0x integration needs a keyed request, a wallet-compatible approval flow and a fresh quote at confirmation. Use this list before enabling the confirm button:
- Get a v2 API key from the 0x dashboard. Choose either AllowanceHolder or Permit2; each has a /price endpoint for display and a /quote endpoint for an executable transaction.
- Send taker, sellToken, buyToken, sellAmount and chainId. Convert sellAmount to the token’s base units so the requested trade matches what the user entered.
- Read liquidityAvailable and issues, especially allowance and balance. An unavailable route, insufficient funds or a required approval needs its own state before confirmation. Approve only the spender returned for the chosen flow.
- Show the quoted output, minimum output, gas and fees so the user can assess price and slippage. If you charge an integrator fee, set swapFeeBps and swapFeeRecipient, and account for the fee token in the displayed result.
- Fetch a new /quote when the user confirms. Sending a stale quote’s transaction can revert as liquidity moves or a quoted order expires; submit the transaction returned with the fresh quote.
- Link out for incidental swaps; integrate when in-app retention or fee revenue matters.
- For smart-contract wallets, start with AllowanceHolder and validate the quote before submission.
Related Questions
Does the 0x Swap API charge fees?
The 0x Swap API can include a 0x fee on select swaps, shown as zeroExFee in the response; gas and any integrator fee are separate. An integrator fee earns your product revenue but changes the user’s trade outcome, so display it alongside the quote. 0x explains the fields in its Swap API FAQ.
Which chains does the 0x Swap API support?
The EVM Swap API supports Ethereum and multiple EVM networks, including Base, Arbitrum and Polygon. Set chainId for each request and verify your launch networks against 0x’s current supported-chains table; coverage can change.
What Should You Solve Next?
How do I handle Permit2 signatures with wagmi or viem?
Use the wallet’s typed-data signing method on the EIP-712 payload returned with a fresh Permit2 quote, then attach the signature as required by that quote’s transaction flow. This gives an EOA granular approval control, but adds a signing prompt and implementation work. For a multisig or smart account, prefer AllowanceHolder’s standard approval flow.
How do I test 0x Swap API on a testnet?
You cannot test the current 0x Swap API on a supported testnet. Use a small trade on a low-cost supported mainnet, such as Base, to exercise real liquidity and transaction execution. That costs actual tokens and gas, but tests the route your users will take. See 0x’s testnet guidance.