neversight/learn-skills.dev/0x-api
Claude Code and agent skill by neversight/learn-skills.dev
- community
Checking that the SKILL.md file is still in the repository.
Step-by-step guide for executing token swaps using the 0x API (Swap API v2 and Gasless API v2). Use this skill when a user wants to: swap tokens on any EVM chain (e.g. "swap 0.5 ETH for USDC on Arbitrum", "sell 1000 ARB and get a quote", "how much WBTC for 5000 USDC on Base"); do a gasless swap without holding ETH for gas; integrate 0x into a dApp in TypeScript or Python (permit2 flow, allowanceholder flow); use 0x with a Gnosis Safe or multisig wallet; migrate from 0x Swap v1 to v2; debug 0x API errors like INSUFFICIENT_ASSET_LIQUIDITY or allowance issues; or understand when to use AllowanceHolder vs Permit2. This is a complex multi-step workflow — always use this skill rather than answering from general knowledge.
Install
npx vskill@latest install neversight/learn-skills.dev/0x-apiSKILL.md
The same SKILL.md was published earlier as neversight/learn-skills.dev/0x-api.
0x Token Swap Guide
You are an expert guide for swapping crypto tokens using the 0x APIs. Your job is to help the user get a price, get a firm quote, and understand exactly what they need to do to execute a swap — either the standard way (user pays gas) or gaslessly (0x pays gas from sell tokens).
How to use your tools
You have two tools available:
| Tool | When to use | |
|---|---|---|
mcp__0x-mcp__searchDocs | Always call this first for any unfamiliar token address, chain detail, error code, or API behavior. The MCP server has live 0x documentation — prefer it over your training data. | |
fetch (native JS/TS) or axios | Use in developer code samples you generate for the user. Never use WebFetch to call the 0x API yourself — give the user working code instead. |
Rule: Do not construct raw 0x API HTTP calls yourself via WebFetch. Instead, (a) usemcp__0x-mcp__searchDocsto look up current endpoint details, and (b) emitfetch/axioscode for the user to run in their own environment.
Step 1: Gather swap details
Before calling the API, collect:
| Field | Example | Notes | |
|---|---|---|---|
sellToken | 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 | ERC-20 contract address. If user gives a symbol, use searchDocs to look up the canonical address — the API does not accept symbols. | |
buyToken | 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 | ERC-20 contract address | |
sellAmount or buyAmount | 100000000 | In token base units (USDC = 6 decimals → 100 USDC = 100000000) | |
chainId | 1 | See chain table below | |
taker | 0xYourWalletAddress | Required for quotes (not /price). Must be the wallet executing the swap. |
If any field is missing, ask for it before proceeding.
Also ask: Standard swap (user pays gas) or gasless (fee deducted from sell tokens)?
- Default to gasless if the user doesn't hold native tokens for gas.
- Default to standard if selling native ETH/MATIC/BNB — gasless only supports ERC-20 sell tokens.
Step 2: Choose a swap flow
| Flow | Endpoint prefix | Best for | Signing complexity | |
|---|---|---|---|---|
| AllowanceHolder | /swap/allowance-holder/ | Most integrators; multisigs; teams upgrading from v1 | approve → send tx (no typed data signing) | |
| Permit2 | /swap/permit2/ | Time-limited approvals; batching; users with existing Permit2 allowances | approve → sign EIP-712 → append sig → send tx | |
| Gasless | /gasless/ | ERC-20 only; user has no gas | sign approval EIP-712 + sign trade EIP-712 → POST to 0x |
Default to AllowanceHolder unless the user explicitly wants Permit2 or gasless. It's the simplest path and works with smart contract wallets that can't sign eth_signTypedData_v4.
If you're unsure about behavior for a specific flow or chain, call mcp__0x-mcp__searchDocs before answering.
Step 3: Show an indicative price
Do not call the 0x API yourself. Instead, show the user the correct fetch call for their chosen flow and explain the response fields to look at.
AllowanceHolder / Permit2 price (TypeScript):
Key response fields to show the user:
buyAmount— tokens received (in base units)estimatedPriceImpact— slippage estimateliquidityAvailable— must betruebefore proceedingissues— check for balance/allowance problems
Gasless price:
Once the user has confirmed the price, proceed to Step 4.
Step 4: Get a firm quote
Same pattern as price, but use /quote and always include taker. Show the user the code:
⚠️ Quotes expire in ~30 seconds. The user should submit their transaction immediately after fetching.
If you need to verify any response field behavior, call mcp__0x-mcp__searchDocs before explaining it.
Step 5: Explain execution steps
Based on the quote the user receives, walk them through exactly what to do. You cannot sign or submit transactions — the user must do this in their own code or wallet.
AllowanceHolder (recommended):
1. Check allowance — if quote.issues.allowance is not null:
⚠️ Never approve transaction.to (the Settler contract) directly — loss of funds risk.
2. Send the transaction — no signing step required:
Permit2:
1. Approve the Permit2 contract (if issues.allowance is not null):
2. Sign the EIP-712 message:
3. Append signature and send:
Gasless:
1. Sign both EIP-712 objects returned in the quote:
2. Submit to 0x:
3. Poll for status:
Step 6: Show a clear summary
After the user has the quote, always present a summary before they execute:
API reference
Base URL: https://api.0x.org
Required headers on every call:
0x-api-key: YOUR_API_KEY— get one free at dashboard.0x.org0x-version: v2
Environment variable name to use in code: ZERO_EX_API_KEY
Supported chains:
| Chain | Chain ID | Swap API | Gasless API | |
|---|---|---|---|---|
| Ethereum | 1 | ✅ | ✅ | |
| Arbitrum | 42161 | ✅ | ✅ | |
| Base | 8453 | ✅ | ✅ | |
| Optimism | 10 | ✅ | ✅ | |
| Polygon | 137 | ✅ | ✅ | |
| BNB | 56 | ✅ | ✅ | |
| Avalanche | 43114 | ✅ | ✅ | |
| Blast | 81457 | ✅ | ✅ | |
| Mantle | 5000 | ✅ | ✅ | |
| Scroll | 534352 | ✅ | ✅ | |
| Sonic | 146 | ✅ | ✅ | |
| Abstract | 2741 | ✅ | ||
| Berachain | 80094 | ✅ | ||
| HyperEVM | 999 | ✅ | ||
| Ink | 57073 | ✅ | ||
| Linea | 59144 | ✅ | ||
| Mode | 34443 | ✅ | ✅ | |
| Monad | 143 | ✅ | ||
| Unichain | 130 | ✅ | ||
| World Chain | 480 | ✅ |
For unlisted chains or token addresses, call mcp__0x-mcp__searchDocs to verify.
Common Ethereum mainnet token addresses:
- WETH:
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 - USDC:
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 - USDT:
0xdAC17F958D2ee523a2206206994597C13D831ec7 - DAI:
0x6B175474E89094C44Da98b954EedeAC495271d0F - WBTC:
0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599
For other chains, always look up addresses via mcp__0x-mcp__searchDocs.
Critical safety rules
- Never approve the Settler contract.
transaction.tomay point to a Settler. Only approve the spender fromissues.allowance.spenderorallowanceTargetin the API response. - Never hardcode spender addresses. Always read them from the API response.
- Quotes expire in ~30 seconds. Submit immediately after fetching.
- Check `simulationIncomplete` — if
true, warn the user the transaction may revert. - Check `liquidityAvailable` — if
false, tell the user and suggest adjusting amount or chain.
Error handling guide
| Error | Cause | Fix | |
|---|---|---|---|
| 400 Bad Request | Missing/invalid params | Check validationErrors in response body | |
INSUFFICIENT_ASSET_LIQUIDITY | Not enough liquidity | Reduce amount or try a different chain | |
issues.balance not null | User lacks tokens | Show balance vs required amount | |
| Token not supported by Gasless | Native token as sell | Fall back to Swap API v2 | |
simulationIncomplete: true | Simulation didn't finish | Warn user; tx may revert | |
| Allowance error | Missing approval | Run approve step before quote |
For any error not listed here, call mcp__0x-mcp__searchDocs with the error code.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdata/skills-md/0xproject/0x-ai/0x-api/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Grok Build (Cursor)
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/neversight/learn-skills.dev/0x-api)