Issues & Error Codes
Handling API Issues and Error Codes
When working with the 0x API v2, there are two key places to check for errors:
- The
issuesobject: This is returned in the API response when there are validation issues with a quote. It helps identify problems such as insufficient token allowance, low balances, or invalid liquidity sources that could prevent a successful swap execution. - Error codes: These are returned when there is an issue making the API request itself, such as invalid input or authorization errors.
Issues Object
By examining both the issues object for quote validation and the error codes for request failures, developers can troubleshoot and resolve issues more efficiently, ensuring smoother transaction processes.
In rare cases where 0x cannot fully validate a quote, the API returns true in issues.simulationIncomplete. Developers are encouraged to check and address these issues before proceeding with the swap.
Issue Types and Resolutions
Below is a list of the common issues that may arise when using the /price or /quote endpoints, along with their causes and resolutions:
This table format provides a concise and structured way to convey the relevant information about each issue, helping developers quickly understand the cause and resolution for each one.
Best Practices for Handling Issues
Price Requests
allowance: If returned, prompt the user to set the appropriate token allowance before proceeding.balance: Avoid proceeding to the quote stage if the user does not have enough tokens, as indicated by this field.simulationIncomplete: Safe to ignore for price requests. This issue may arise if thetakeraddress is set but has an insufficient token balance.
Quote Requests
allowance: Ensure that users complete the allowance setup before proceeding.balance: This field indicates insufficient token balance; prompt the user to check their balance and retry.simulationIncomplete: Advise users that validation could not be completed, but the trade may still succeed.
Error Codes
In addition to the issues object, the API may return specific error codes under certain conditions. If the error persists, please contact support for assistance.
Common Error Codes