Prerequisites
API Key
Get your API key for authentication at Deframe
Token Addresses
Contract addresses for the tokens you want to swap
Chain IDs
Chain IDs for source and destination chains
Authentication
Include your API key in the
x-api-key headerOverview
The Deframe API supports both same-chain and cross-chain token swaps. The system automatically detects the swap type based on the chain IDs provided and routes to the appropriate provider.Same-chain Swap: When
originChain equals destinationChain
Cross-chain Swap: When originChain differs from destinationChainGetting a Quote
Endpoint
This is a v2 endpoint. Always use
/v2/swap/quote for new integrations — it saves quotes to the database and returns a quoteId required by POST /v2/swap/bytecode.Required Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
originChain | string | Source chain name | ethereum, polygon, arbitrum |
tokenIn | string | Contract address of input token | 0xdAC17F958D2ee523a2206206994597C13D831ec7 (USDT) |
amountIn | string | Amount in token’s smallest unit. Provide either amountIn or amountOut, not both. | 1000000 (1 USDT with 6 decimals) |
amountOut | string | Exact output amount (alternative to amountIn) | 998500 |
destinationChain | string | Target chain name | polygon, ethereum, base |
tokenOut | string | Contract address of output token | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 (USDC) |
Either
amountIn OR amountOut is required (not both). Use amountOut for exact output swaps (“I want to receive exactly X tokens”).Example Requests
Same-Chain Swap (Ethereum USDT to USDC)
Cross-Chain Swap (Ethereum to Polygon)
Response Format
The API returns a JSON object containing the quote details:Response Fields
quoteId
quoteId
Unique identifier for this quote. Use this when executing the swap.
originChain & destinationChain
originChain & destinationChain
Source and destination chain names (e.g.,
ethereum, polygon, arbitrum)tokenIn & tokenOut
tokenIn & tokenOut
Complete token information including contract address, symbol, decimals, amount, and chain ID
provider
provider
Name of the swap provider used (e.g.,
1inch, Jupiter, TeleSwap, Mayan)deadline
deadline
Quote expiration as a Unix timestamp in seconds. Execute the swap before this time.
rawQuote
rawQuote
Provider-specific quote data (stringified JSON). Some bridge providers require this for bytecode generation. This field is omitted from the response when null — only pass it to the bytecode endpoint when present.
Supported Chains
Ethereum
ethereumBase
baseOptimism
optimismArbitrum
arbitrumSolana
solanaPolygon
polygonGnosis
gnosisBitcoin
bitcoinError Handling
The API returns appropriate error messages for:- Missing required parameters
- Invalid chain names or token addresses
- No available swap provider for the requested route
- Provider-specific errors during quote generation
| Error Code | Message |
|---|---|
AMOUNT_IN_TOO_HIGH | AmountIn must be less than 5k USDC |
AMOUNT_OUT_TOO_HIGH | AmountOut must be less than 26k BRLA |
Next Steps
Execute Swap
Use the quote to generate bytecode and execute the swap
API Reference
View detailed API documentation