API reference

Getting started with the 0x API
View as Markdown

Introduction

The 0x API provides a unified interface for liquidity aggregation, token swap pricing, and onchain trading across major supported blockchains. It is designed to help developers easily integrate token swaps and routing logic without managing individual DEX integrations.

The 0x API exposes endpoints for the following core capabilities:

  • Swap: Generate executable quotes and calldata for token swaps using either the AllowanceHolder (recommended) or Permit2 approval models. Learn more in the FAQ.
  • Gasless: Enable gasless swaps by sponsoring transaction fees on behalf of users, improving UX for end-user applications.
  • Sources: Retrieve supported liquidity sources, chains, and token metadata used by the 0x routing engine.
  • Trade Analytics: Query historical trade data, volumes, and execution details for monitoring and analytics use cases.

Each API surface is documented in detail in the sections below.

Base URL

All requests to the 0x API must be made to the following base URL:

https://api.0x.org

All requests must be sent over HTTPS. Requests made over HTTP will be rejected.

Authentication

All 0x API requests require an API key. Include your API key in the following request header:

0x-api-key
stringRequired

Your 0x API key used to authenticate requests.

0x-version
stringRequired

0x API version.

Requests missing this header may be rate-limited or rejected.

You can generate and manage API keys from the 0x Dashboard.

Chain Support

The 0x API supports multiple EVM-compatible chains. Each request must specify a chain either via the request path or query parameters, depending on the endpoint.

Refer to the Supported Chains for a complete and up-to-date list.

Examples

1const params = new URLSearchParams({
2 sellAmount: "100000000000000000000000", // 100,000 WETH
3 taker: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", // vitalik.eth
4 chainId: "1",
5 sellToken: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH
6 buyToken: "0x6b175474e89094c44da98b954eedeac495271d0f", // DAI
7});
8
9fetch(`https://api.0x.org/swap/allowance-holder/quote?${params.toString()}`, {
10 headers: {
11 "0x-api-key": "YOUR_API_KEY",
12 "0x-version": "v2",
13 "Content-Type": "application/json",
14 },
15})
16 .then((res) => res.json())
17 .then((data) => console.log(data));