0x API v1 was be sunset on April 11, 2025. To ensure uninterrupted service, please migrate to v2 before this date. If you have any questions, feel free to contact support.
0x Gasless API has undergone a major upgrade that introduces new features that require a new integration. This new version offers:
⚡️ Quicklinks
Find the latest API reference here.
This section showcases example requests and responses for both the v1 and v2 endpoints to illustrate updates in the shape of the query and responses made during the API upgrade:
Gasless API v1 /quote
Gasless API v2 /quote
The chain is no longer designated in the header. All chains now use the same https://api.0x.org endpoint, with the chain set via the new chainId query parameter.
The API version is no longer set in the endpoint URL. In v2, the API version is a required header parameter.
The endpoint is now /gasless/ instead of tx-relay/.
Note the following parameter names have been updated in v2. See the API reference for more parameter details:
takerAddress has been renamed to takersellTokenAddress has been renamed to sellTokenbuyTokenAddress has been renamed to buyTokenThe buyAmount query parameter has been deprecated in favor of purely sellAmount for more deterministic behavior. When using sellAmount, any unused tokens are refunded to the user, whereas using buyAmount can lead to over-buying due to slippage and varying liquidity source behaviors. Additionally, some liquidity sources (e.g., Kyber) do not support quoting by buyAmount, which limits available liquidity.
Old (v1):
New (v2):
There is a new liquidityAvailable field that validates the availability of liquidity for a price or quote request. All other parameters will only be returned when this is returned as true.
To help provide developers a smooth build experience, 0x API v2 will do as much validation as it can and report all issues it finds in the new issues object. This object returns a list of potential validation issues detected with the quote. In rare cases where we are unable to validate the quote, we’ll return true in issues.simulationIncomplete. Learn more about the new issues object and how you can use it to provide a better experience for your users.
Note the following about the issues object for Price and Quote:
Price
allowance: If this field is not null, prompt the user to set the allowance on issues.allowance.spenderbalance: If this field is not null, do not proceed to get a quote.simulationIncomplete: This field can be ignored for price since when calling price means aren’t close to submitting a transaction (versus calling quote). Typically simulationIncomplete: true won’t occur if the taker address is set and the taker has a sufficient balance of the sell token.Quote
allowance: This field should not appear if the quote is sent after the token allowance is set.balance: This field will not be returned if the taker has sufficient balance when the quote request is sent.simulationIncomplete: true: This field will not be returned if the taker has sufficient balance when the quote request is sent.With the introduction of the issues.allowance field in Gasless API v2, some fields in approval field in Gasless API v1 become unnecessary. Specifically, approval.isRequired and approval.isGaslessAvailable fields have been deprecated in v2. Here is how to translate between the new fields in v2 and the old fields in v1.
In v2, for tokens that do not support gasless approvals, use the standard token approval flow.
When using the Standard Approval Flow (aka Gasless Approvals are not supported)
NEVER set an allowance on the Settler contract. Doing so may result in unintended consequences, including potential loss of tokens or exposure to security risks. The Settler contract does not support or require token allowances for its operation. Setting an allowance on the Settler contract will lead to misuse by other parties.
ONLY set allowances on AllowanceHolder or Permit2 contracts, as indicated by the API responses.
The correct allowance target is returned in issues.allowance.spender or allowanceTarget.
Overview of how to update Gasless API price and quote to handle the new v2 endpoints.
⚡️ See these steps in action in the Gasless headless example
/gasless/price (code)
chainId as new param (no longer in the header)takerAddress has changed to takersellTokenAddress changed to sellToken, buyTokenAddress changed to buyToken/gasless/quote (code)
taker address)
chainId as new param (no longer in the header)takerAddress has changed to takersellTokenAddress changed to sellToken, buyTokenAddress changed to buyToken (code)issues.allowance != null; (code)approval != null; (code)/gasless/submit (code)/gasless/submit will return tradeHash which is the hash for the trade according to EIP-712
tradeHash returned matches the settler_metatransaction providedtradeHash returned by /submit to poll /gasless/status/{tradeHash} to confirm if the trade has been successfully submitted (code)