get_quote
Get a swap quote with routing preview. Read-only price check — does NOT execute.
Tier: Free
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sellToken | string | Yes | Token to sell — symbol (e.g. “USDC”) or contract address |
buyToken | string | Yes | Token to buy — symbol or contract address |
sellAmount | string | Yes | Amount to sell in human-readable units (e.g. “100”) |
chainId | number | No | Chain ID (default: 1) |
Example
"Get me a quote for swapping 100 USDC to ETH on Ethereum"Response
Returns:
- Input and output amounts
- Exchange rate
- Protocol used (0x or 1inch)
- Estimated gas
Implementation
- Resolves token symbols to contract addresses
- Tries 0x API first, falls back to 1inch
- Returns formatted quote with rate calculation
Notes
- Requires
ZEROX_API_KEYorONEINCH_API_KEY - Use the
swapwrite tool to execute the quote