canonical: https://jentic.com/apis/api.0x.org/0x

# 0x API

The 0x API v2 aggregates liquidity from on-chain DEXs and off-chain market makers across Ethereum and dozens of other EVM chains, returning the best executable price and a ready-to-sign transaction for a token swap. Two flavours are exposed: an Allowance Holder flow that uses a single approval contract, and a Permit2 flow that signs token allowances per trade. A separate Gasless endpoint set lets users trade without holding the native gas token by relaying signed messages. Designed for wallets, trading bots, and DeFi front ends that need consistent best-of-route pricing.

## For AI agents

Get the best swap price and an executable transaction across DEX liquidity on Ethereum and other EVM chains, including gasless trading flows.

## Scope

Does not handle fiat on-ramps, custody, or non-EVM chains - use for ERC-20 swap quoting and gasless trade relaying only.

## Capabilities

- Fetch the best indicative price for an ERC-20 token swap via /swap/permit2/price
- Generate a signable swap transaction with calldata through /swap/permit2/quote
- Run swaps using the Allowance Holder pattern via /swap/allowance-holder/price and /quote
- Quote and submit gasless trades through /gasless/price, /gasless/quote, and /gasless/submit
- Track the status of a relayed gasless trade by tradeHash with /gasless/status/{tradeHash}
- Inspect which liquidity sources contributed to a quote via /sources

## Use cases

### Token swap in a wallet or trading agent

Power the swap tab of a self-custodial wallet or an automated trading agent by quoting and executing ERC-20 swaps across aggregated liquidity. /swap/permit2/price returns the indicative rate and gas estimate, /swap/permit2/quote returns the calldata that the wallet signs and broadcasts. The aggregated routing across Uniswap, Curve, and major market makers usually produces a better fill than calling a single DEX directly.

Example prompt: Call /swap/permit2/quote with sellToken=USDC, buyToken=WETH, sellAmount=1000000000 and chainId=1, then return the to, data, and value fields ready for signing.

### Gasless trading for new users

Let users swap tokens even when their wallet has zero native gas balance. The /gasless/quote endpoint returns a meta-transaction the user signs, /gasless/submit relays it through 0x's network, and /gasless/status/{tradeHash} reports settlement. This removes the most common onboarding failure in DeFi (user has stablecoin but no ETH) and is suitable for fintech wallets and onboarding flows.

Example prompt: Get a /gasless/quote for sellToken=USDC and buyToken=DAI, have the user sign the EIP-712 payload, submit via /gasless/submit, then poll /gasless/status/{tradeHash} until status=succeeded.

### Liquidity routing analytics

Build a dashboard showing where 0x is sourcing liquidity for given pairs by combining /sources with periodic /price calls. Useful for treasuries, DEX research, and DeFi monitoring tools that want to know whether a quote came from an on-chain pool, an RFQ market maker, or a hybrid route. Helps explain slippage and prove best-execution to compliance.

Example prompt: Call /sources?chainId=1 to list active sources, then /swap/permit2/price for WETH > USDC and parse the route field to attribute fill share to each source.

### Agent integration via Jentic

Give a DeFi agent a typed swap tool that returns ready-to-sign transactions instead of expecting it to assemble calldata from raw on-chain calls. Through Jentic the agent loads the /swap/permit2/quote schema, supplies sellToken, buyToken, and amount, and receives back the transaction object. The 0x API key sits in your Jentic One instance and is injected at execution.

Example prompt: Search Jentic for 'swap tokens on Ethereum', load /swap/permit2/quote, and execute it with sellToken=DAI, buyToken=WETH, sellAmount=500000000000000000000.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | /swap/permit2/price | Indicative swap price using Permit2 |
| GET | /swap/permit2/quote | Executable swap transaction using Permit2 |
| GET | /swap/allowance-holder/price | Indicative swap price using Allowance Holder |
| GET | /swap/allowance-holder/quote | Executable swap transaction using Allowance Holder |
| GET | /gasless/quote | Quote a gasless meta-transaction swap |
| POST | /gasless/submit | Submit a signed gasless trade for relaying |
| GET | /gasless/status/{tradeHash} | Check settlement status of a gasless trade |

## Key resources

- **Swap (Permit2)** — Price and quote endpoints for swaps using the Permit2 allowance pattern
- **Swap (Allowance Holder)** — Price and quote endpoints for swaps using the legacy allowance pattern
- **Gasless** — Quote, submit, and status endpoints for relayed gasless trades
- **Sources** — List of liquidity sources currently active per chain

## Why Jentic

- **Setup:** Wiring the 0x API by hand means handling its 0x-api-key header, choosing between Permit2, Allowance Holder, and gasless swap flows, and mapping the price, quote, and submit routes yourself. Through Jentic you install once, import 0x from the API Directory, store the key once, and your agent calls it.
- **Permission scoping:** 0x selects quotes through query parameters rather than resource ids in the URL path, so you limit the agent to the operations it needs, such as fetching a Permit2 or Allowance Holder price. Gasless submit and status are separate operations that are only available if you include them in the allowed set.
- **Credential handling:** Your 0x-api-key is stored once, encrypted, by your own Jentic One instance and injected as the header at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'swap USDC for ETH at the best price', and Jentic returns the matching 0x operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Uniswap API** — Single-DEX swap routing on Uniswap pools instead of cross-aggregator routing
- **Alchemy API** — Underlying RPC and on-chain data provider used to broadcast 0x swap transactions
- **CoinGecko API** — Market reference prices to compare against 0x quotes for slippage analysis

## FAQ

### What authentication does the 0x API use?

The 0x API uses an API key passed in the 0x-api-key header. Keys are issued from the 0x dashboard at 0x.org and tier-rate-limited. When the API is called through Jentic the key is held in your Jentic One instance and injected into the request, so it never enters the agent's prompt context.

### What is the difference between the Permit2 and Allowance Holder swap flows?

The Allowance Holder flow uses a single contract approval that the user grants once, while the Permit2 flow uses signed permissions per trade so the user does not have to send a separate approval transaction. Permit2 is recommended for new integrations; Allowance Holder remains supported via /swap/allowance-holder/price and /swap/allowance-holder/quote.

### How do gasless trades work on the 0x API?

Call /gasless/quote to get a signable meta-transaction, have the user sign it, then submit via /gasless/submit. 0x relays the signed message and pays the gas, deducting it from the user's swap proceeds. Use /gasless/status/{tradeHash} to track settlement.

### What are the rate limits for the 0x API?

Free-tier keys are limited to a small number of requests per second; paid tiers raise the limit. The exact number is shown on the 0x dashboard against your key. Quote endpoints are more expensive than price endpoints, so cache /swap/permit2/price responses where possible.

### How do I execute a token swap through Jentic?

Search Jentic for 'swap tokens on Ethereum', load the /swap/permit2/quote operation, and execute it with sellToken, buyToken, sellAmount, and chainId. The response contains the to, data, value, and gas fields, which the agent passes to a wallet for signing and broadcasting.

### Which chains does the 0x API support?

0x API v2 supports Ethereum mainnet plus dozens of EVM chains including Polygon, Arbitrum, Optimism, Base, BNB Chain, and Avalanche. Pass the target network via the chainId parameter on every request - the same endpoints work across all supported chains.

### Can I limit what my agent is allowed to do with the 0x API?

Yes. Because you run Jentic One yourself, your own rules decide which 0x operations and credentials the agent may use, and the 0x API selects trades through query parameters rather than resource IDs in the URL path, so you scope access by operation. You can allow read-only pricing such as /swap/permit2/price or /swap/allowance-holder/price while withholding the operations that move value. The gasless submit and status operations, /gasless/submit and /gasless/status/{tradeHash}, are separate and reach the agent only if you add them to the allowed set. Your 0x-api-key stays in your own instance and is injected at execution, so the agent never sees it.
