A collection of 0x API code examples
⚠️ WARNING — READ BEFORE USING 0x API
NEVER set an allowance on the Settler contract.
Doing so may lead to loss of tokens or security risks.
The Settler contract does not require allowances — setting one enables misuse by other parties.ONLY set allowances on Permit2 or AllowanceHolder contracts, as indicated by the API response.
The correct allowance target is returned in
issues.allowance.spender
.
- The examples in this repo are demos, and are not ready for production use. The code has not been audited and does not account for all error handling. Use at your own risk.
- Swap API v2 Demo App (Permit2) using Next.js App Router
- Swap API v2 (Permit2) Headless Example
- Swap API v2 (AllowanceHolder) Headless Example
- Use Swap API v2 in Your Smart Contract with Foundry
Warning
0x API v1 was sunset on April 11, 2025. Please migrate to v2. For details, see the migration guide.
- Swap API v1 Demo App using Next.js App Router
- Swap API v1 Demo App using Next.js Pages Router
- Swap API v1 Demo App using HTML/CSS/JavaScript
- Swap API v1 Headless Example
-
Fork the Repository: Start by forking the repository and creating a new branch for your contributions.
-
Set Up Environment: Follow the setup guide in the README to ensure your environment matches the development requirements.
-
Code Standards: Adhere to the ESLint rules provided in the project
-
Documentation: Include or update relevant documentation for new features or changes.
-
Pull Request:
- Provide a clear description of the changes and the issue(s) addressed
- Tag at least one maintainer for review
- Include screenshots or logs for UI changes or CLI commands
-
Be Respectful: Treat others with respect and kindness in all interactions.
-
Constructive Feedback: Provide feedback that is thoughtful, helpful, and actionable.
-
No Harassment: Harassment, abusive language, or any form of discrimination will not be tolerated.
-
Collaborative Environment: Support an open and welcoming space for contributors from all backgrounds.
Copyright 2025 ZeroEx Labs
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at LICENSE for details.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
For bugs, feature requests, and other inquiries related to this example, please open an issue on the GitHub repository.
The 0x developer support team is available to quickly answer your technical questions. Contact the support team either through the "Intercom messenger" in the bottom right corner throughout the 0x.org.