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
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 of input tokens to swap | 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 timestamp. Execute the swap before this time.
rawQuote
rawQuote
Provider-specific quote data. Pass this to the bytecode endpoint.
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