Skip to main content

0x API (next)

Download OpenAPI specification:Download

These are the API references for the beta version of 0x API v2. If you are looking for API v1 references, see here.

Swap

Swap API endpoints

getPrice (Permit2)

Get the indicative price for a swap using Permit2 to set allowances

query Parameters
chainId
required
integer > 0
Example: chainId=1

Chain ID. See here for the list of supported chains

buyToken
required
string^0x[a-fA-F0-9]{40}$
Example: buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7

The contract address of the token to buy

sellToken
required
string^0x[a-fA-F0-9]{40}$
Example: sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

The contract address of the token to sell

sellAmount
required
string
Example: sellAmount=100000000

The amount of sellToken in sellToken base units to sell

taker
string^0x[a-fA-F0-9]{40}$
Example: taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e

The address which holds the sellToken balance and has the allowance set for the swap

txOrigin
string^0x[a-fA-F0-9]{40}$

The contract address of the external account that started the transaction. This is only needed if taker is a smart contract.

swapFeeRecipient
string^0x[a-fA-F0-9]{40}$

The wallet address to receive the specified trading fees. You must also specify the swapFeeToken and swapFeeBps in the request to use this feature. Learn more about setting up a trading fee/commission in the FAQs

swapFeeBps
integer [ 0 .. 1000 ]

The amount in Bps of the swapFeeToken to charge and deliver to the swapFeeRecipient. You must also specify the swapFeeRecipient and swapFeeToken in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us.

swapFeeToken
string^0x[a-fA-F0-9]{40}$

The contract address of the token to receive trading fees in. This must be set to the value of either the buyToken or the sellToken. You must also specify the swapFeeRecipient and swapFeeBps in the request to use this feature

tradeSurplusRecipient
string^0x[a-fA-F0-9]{40}$

The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus

gasPrice
string

The target gas price (in wei) for the swap transaction. If not provided, the default value is based on the 0x gas price oracle

slippageBps
integer [ 0 .. 10000 ]
Default: 100

The maximum acceptable slippage of the buyToken in Bps. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100Bps

excludedSources
string

Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. See https://api.0x.org/sources?chainId= with the desired chain's ID for a full list of sources. Separate multiple sources with a comma

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Responses

Response samples

Content type
application/json
{
  • "blockNumber": "20114676",
  • "buyAmount": "100032748",
  • "buyToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  • "fees": {
    },
  • "gas": "288095",
  • "gasPrice": "7062490000",
  • "issues": {
    },
  • "liquidityAvailable": true,
  • "minBuyAmount": "99032421",
  • "route": {
    },
  • "sellAmount": "100000000",
  • "sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  • "tokenMetadata": {
    },
  • "totalNetworkFee": "2034668056550000",
  • "zid": "0x111111111111111111111111"
}

getQuote (Permit2)

Get the firm quote for a swap using Permit2 to set allowances

query Parameters
chainId
required
integer > 0
Example: chainId=1

Chain ID. See here for the list of supported chains

buyToken
required
string^0x[a-fA-F0-9]{40}$
Example: buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7

The contract address of the token to buy

sellToken
required
string^0x[a-fA-F0-9]{40}$
Example: sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

The contract address of the token to sell

sellAmount
required
string
Example: sellAmount=100000000

The amount of sellToken in sellToken base units to sell

taker
required
string^0x[a-fA-F0-9]{40}$
Example: taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e

The address which holds the sellToken balance and has the allowance set for the swap

txOrigin
string^0x[a-fA-F0-9]{40}$

The contract address of the external account that started the transaction. This is only needed if taker is a smart contract.

swapFeeRecipient
string^0x[a-fA-F0-9]{40}$

The wallet address to receive the specified trading fees. You must also specify the swapFeeToken and swapFeeBps in the request to use this feature. Learn more about setting up a trading fee/commission in the FAQs

swapFeeBps
integer [ 0 .. 1000 ]

The amount in Bps of the swapFeeToken to charge and deliver to the swapFeeRecipient. You must also specify the swapFeeRecipient and swapFeeToken in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us.

swapFeeToken
string^0x[a-fA-F0-9]{40}$

The contract address of the token to receive trading fees in. This must be set to the value of either the buyToken or the sellToken. You must also specify the swapFeeRecipient and swapFeeBps in the request to use this feature

tradeSurplusRecipient
string^0x[a-fA-F0-9]{40}$

The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus

gasPrice
string

The target gas price (in wei) for the swap transaction. If not provided, the default value is based on the 0x gas price oracle

slippageBps
integer [ 0 .. 10000 ]
Default: 100

The maximum acceptable slippage of the buyToken in Bps. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100Bps

excludedSources
string

Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. See https://api.0x.org/sources?chainId= with the desired chain's ID for a full list of sources. Separate multiple sources with a comma

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Responses

Response samples

Content type
application/json
{
  • "blockNumber": "20114692",
  • "buyAmount": "100037537",
  • "buyToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  • "fees": {
    },
  • "issues": {
    },
  • "liquidityAvailable": true,
  • "minBuyAmount": "99037162",
  • "permit2": {
    },
  • "route": {
    },
  • "sellAmount": "100000000",
  • "sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  • "tokenMetadata": {
    },
  • "totalNetworkFee": "1393685870940000",
  • "transaction": {
    },
  • "zid": "0x111111111111111111111111"
}

getPrice (Allowance Holder)

Get the indicative price for a swap using Allowance Holder to set allowances

query Parameters
chainId
required
integer > 0
Example: chainId=1

Chain ID. See here for the list of supported chains

buyToken
required
string^0x[a-fA-F0-9]{40}$
Example: buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7

The contract address of the token to buy

sellToken
required
string^0x[a-fA-F0-9]{40}$
Example: sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

The contract address of the token to sell

sellAmount
required
string
Example: sellAmount=100000000

The amount of sellToken in sellToken base units to sell

taker
string^0x[a-fA-F0-9]{40}$
Example: taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e

The address which holds the sellToken balance and has the allowance set for the swap

txOrigin
string^0x[a-fA-F0-9]{40}$

The contract address of the external account that started the transaction. This is only needed if taker is a smart contract.

swapFeeRecipient
string^0x[a-fA-F0-9]{40}$

The wallet address to receive the specified trading fees. You must also specify the swapFeeToken and swapFeeBps in the request to use this feature. Learn more about setting up a trading fee/commission in the FAQs

swapFeeBps
integer [ 0 .. 1000 ]

The amount in Bps of the swapFeeToken to charge and deliver to the swapFeeRecipient. You must also specify the swapFeeRecipient and swapFeeToken in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us.

swapFeeToken
string^0x[a-fA-F0-9]{40}$

The contract address of the token to receive trading fees in. This must be set to the value of either the buyToken or the sellToken. You must also specify the swapFeeRecipient and swapFeeBps in the request to use this feature

tradeSurplusRecipient
string^0x[a-fA-F0-9]{40}$

The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus

gasPrice
string

The target gas price (in wei) for the swap transaction. If not provided, the default value is based on the 0x gas price oracle

slippageBps
integer [ 0 .. 10000 ]
Default: 100

The maximum acceptable slippage of the buyToken in Bps. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100Bps

excludedSources
string

Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. See https://api.0x.org/sources?chainId= with the desired chain's ID for a full list of sources. Separate multiple sources with a comma

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Responses

Response samples

Content type
application/json
{
  • "blockNumber": "20114676",
  • "buyAmount": "100032748",
  • "buyToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  • "fees": {
    },
  • "gas": "288095",
  • "gasPrice": "7062490000",
  • "issues": {
    },
  • "liquidityAvailable": true,
  • "minBuyAmount": "99032421",
  • "route": {
    },
  • "sellAmount": "100000000",
  • "sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  • "tokenMetadata": {
    },
  • "totalNetworkFee": "2034668056550000",
  • "zid": "0x111111111111111111111111"
}

getQuote (Allowance Holder)

Get the firm quote for a swap using Allowance Holder to set allowances

query Parameters
chainId
required
integer > 0
Example: chainId=1

Chain ID. See here for the list of supported chains

buyToken
required
string^0x[a-fA-F0-9]{40}$
Example: buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7

The contract address of the token to buy

sellToken
required
string^0x[a-fA-F0-9]{40}$
Example: sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

The contract address of the token to sell

sellAmount
required
string
Example: sellAmount=100000000

The amount of sellToken in sellToken base units to sell

taker
required
string^0x[a-fA-F0-9]{40}$
Example: taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e

The address which holds the sellToken balance and has the allowance set for the swap

txOrigin
string^0x[a-fA-F0-9]{40}$

The contract address of the external account that started the transaction. This is only needed if taker is a smart contract.

swapFeeRecipient
string^0x[a-fA-F0-9]{40}$

The wallet address to receive the specified trading fees. You must also specify the swapFeeToken and swapFeeBps in the request to use this feature. Learn more about setting up a trading fee/commission in the FAQs

swapFeeBps
integer [ 0 .. 1000 ]

The amount in Bps of the swapFeeToken to charge and deliver to the swapFeeRecipient. You must also specify the swapFeeRecipient and swapFeeToken in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us.

swapFeeToken
string^0x[a-fA-F0-9]{40}$

The contract address of the token to receive trading fees in. This must be set to the value of either the buyToken or the sellToken. You must also specify the swapFeeRecipient and swapFeeBps in the request to use this feature

tradeSurplusRecipient
string^0x[a-fA-F0-9]{40}$

The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus

gasPrice
string

The target gas price (in wei) for the swap transaction. If not provided, the default value is based on the 0x gas price oracle

slippageBps
integer [ 0 .. 10000 ]
Default: 100

The maximum acceptable slippage of the buyToken in Bps. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100Bps

excludedSources
string

Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. See https://api.0x.org/sources?chainId= with the desired chain's ID for a full list of sources. Separate multiple sources with a comma

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Responses

Response samples

Content type
application/json
{
  • "blockNumber": "20114692",
  • "buyAmount": "100037537",
  • "buyToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  • "fees": {
    },
  • "issues": {
    },
  • "liquidityAvailable": true,
  • "minBuyAmount": "99037162",
  • "route": {
    },
  • "sellAmount": "100000000",
  • "sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  • "tokenMetadata": {
    },
  • "totalNetworkFee": "1393685870940000",
  • "transaction": {
    },
  • "zid": "0x111111111111111111111111"
}

Gasless

Gasless API endpoints

getPrice

Get the indicative price for a gasless swap

query Parameters
chainId
required
integer > 0
Example: chainId=1

Chain ID. See here for the list of supported chains

buyToken
required
string^0x[a-fA-F0-9]{40}$
Example: buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7

The contract address of the token to buy

sellToken
required
string^0x[a-fA-F0-9]{40}$
Example: sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

The contract address of the token to sell. Native token is not supported

sellAmount
required
string
Example: sellAmount=300000000

The amount of sellToken in sellToken base units to sell

taker
string^0x[a-fA-F0-9]{40}$
Example: taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e

The address which holds the sellToken balance and has the allowance set for the swap

swapFeeRecipient
string^0x[a-fA-F0-9]{40}$

The wallet address to receive the specified trading fees. You must also specify the swapFeeToken and swapFeeBps in the request to use this feature. Learn more about setting up a trading fee/commission in the FAQs

swapFeeBps
integer [ 0 .. 1000 ]

The amount in Bps of the swapFeeToken to charge and deliver to the swapFeeRecipient. You must also specify the swapFeeRecipient and swapFeeToken in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us.

swapFeeToken
string^0x[a-fA-F0-9]{40}$

The contract address of the token to receive trading fees in. This must be set to the value of either the buyToken or the sellToken. You must also specify the swapFeeRecipient and swapFeeBps in the request to use this feature

tradeSurplusRecipient
string^0x[a-fA-F0-9]{40}$

The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus

slippageBps
integer [ 30 .. 10000 ]

The maximum acceptable slippage of the buyToken in Bps. 0x sets the optimal slippage tolerance per trade by default. To mitigate the risk of MEV attacks, we recommend adjusting this value only when trading low-liquidity tokens.

excludedSources
string

Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. See https://api.0x.org/sources?chainId= with the desired chain's ID for a full list of sources. Separate multiple sources with a comma

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Responses

Response samples

Content type
application/json
{
  • "blockNumber": "20114764",
  • "buyAmount": "291527064",
  • "buyToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  • "fees": {
    },
  • "issues": {
    },
  • "liquidityAvailable": true,
  • "minBuyAmount": "290652483",
  • "route": {
    },
  • "sellAmount": "300000000",
  • "sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  • "target": "0x7c39a136ea20b3483e402ea031c1f3c019bab24b",
  • "tokenMetadata": {
    },
  • "zid": "0x111111111111111111111111"
}

getQuote

Get the firm quote for a gasless swap

query Parameters
chainId
required
integer > 0
Example: chainId=1

Chain ID. See here for the list of supported chains

buyToken
required
string^0x[a-fA-F0-9]{40}$
Example: buyToken=0xdac17f958d2ee523a2206206994597c13d831ec7

The contract address of the token to buy

sellToken
required
string^0x[a-fA-F0-9]{40}$
Example: sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

The contract address of the token to sell. Native token is not supported

sellAmount
required
string
Example: sellAmount=300000000

The amount of sellToken in sellToken base units to sell

taker
required
string^0x[a-fA-F0-9]{40}$
Example: taker=0x70a9f34f9b34c64957b9c401a97bfed35b95049e

The address which holds the sellToken balance and has the allowance set for the swap

swapFeeRecipient
string^0x[a-fA-F0-9]{40}$

The wallet address to receive the specified trading fees. You must also specify the swapFeeToken and swapFeeBps in the request to use this feature. Learn more about setting up a trading fee/commission in the FAQs

swapFeeBps
integer [ 0 .. 1000 ]

The amount in Bps of the swapFeeToken to charge and deliver to the swapFeeRecipient. You must also specify the swapFeeRecipient and swapFeeToken in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us.

swapFeeToken
string^0x[a-fA-F0-9]{40}$

The contract address of the token to receive trading fees in. This must be set to the value of either the buyToken or the sellToken. You must also specify the swapFeeRecipient and swapFeeBps in the request to use this feature

tradeSurplusRecipient
string^0x[a-fA-F0-9]{40}$

The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus

slippageBps
integer [ 30 .. 10000 ]

The maximum acceptable slippage of the buyToken in Bps. 0x sets the optimal slippage tolerance per trade by default. To mitigate the risk of MEV attacks, we recommend adjusting this value only when trading low-liquidity tokens.

excludedSources
string

Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. See https://api.0x.org/sources?chainId= with the desired chain's ID for a full list of sources. Separate multiple sources with a comma

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Responses

Response samples

Content type
application/json
{
  • "approval": {
    },
  • "blockNumber": "20114747",
  • "buyAmount": "292995086",
  • "buyToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  • "fees": {
    },
  • "issues": {
    },
  • "liquidityAvailable": true,
  • "minBuyAmount": "292116101",
  • "route": {
    },
  • "sellAmount": "300000000",
  • "sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  • "target": "0x7c39a136ea20b3483e402ea031c1f3c019bab24b",
  • "tokenMetadata": {
    },
  • "trade": {
    },
  • "zid": "0x111111111111111111111111"
}

submit

Submit a gasless swap

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Request Body schema: application/json
required
chainId
required
integer > 0

Chain ID. See here for the list of supported chains

object or null

The gasless approval object from the quote endpoint including its signature

required
object

The trade object from the quote endpoint including its signature

Responses

Request samples

Content type
application/json
{
  • "approval": {
    },
  • "chainId": 8453,
  • "trade": {
    }
}

Response samples

Content type
application/json
{
  • "tradeHash": "0xcb3285b35c024fca76037bea9ea4cb68645fed3bdd84030956577de2f1592aa9",
  • "type": "settler_metatransaction",
  • "zid": "0x111111111111111111111111"
}

getStatus

Get the status of a gasless swap

path Parameters
tradeHash
required
string
Example: 0x6c89e4ac46b246ab72cba02a9fb4f3525b9f8a11ea74262d5dd8ff0e024daf60

The hash for the trade according to EIP-712

query Parameters
chainId
required
integer > 0
Example: chainId=8453

here for the list of supported chains

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Responses

Response samples

Content type
application/json
{
  • "status": "confirmed",
  • "transactions": [
    ],
  • "zid": "0x111111111111111111111111"
}

getGaslessApprovalTokens

Get token addresses that support gasless approvals

query Parameters
chainId
required
integer > 0
Example: chainId=8453

Chain ID. See here for the list of supported chains

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Responses

Response samples

Content type
application/json
{
  • "tokens": [
    ],
  • "zid": "0x111111111111111111111111"
}

Sources

Sources API endpoints

getSources

Get the list of supported sources

query Parameters
chainId
required
integer > 0
Example: chainId=1

Chain ID. See here for the list of supported chains

header Parameters
0x-api-key
required
string

Visit dashboard.0x.org to get your API Key

0x-version
required
string
Example: v2

API version

Responses

Response samples

Content type
application/json
{
  • "sources": [
    ],
  • "zid": "0x111111111111111111111111"
}