In this section, you’ll learn how to request quotes for swapping between tokens using the Deframe API.Documentation Index
Fetch the complete documentation index at: https://docs.deframe.io/llms.txt
Use this file to discover all available pages before exploring further.
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 or chainIdIn | string or number | Source chain name, or source chain ID. Use one of these fields. | ethereum, 1 |
destinationChain or chainIdOut | string or number | Destination chain name, or destination chain ID. Use one of these fields. | polygon, 137 |
tokenIn | string | Contract address of input token | 0xdAC17F958D2ee523a2206206994597C13D831ec7 (USDT) |
tokenOut | string | Contract address of output token | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 (USDC) |
amountIn or amountOut | string | Amount in the token’s smallest unit. Provide exactly one of these fields. | 1000000 |
Optional Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
preferredProvider | string | Force a specific swap provider for the returned quote when multiple providers support the route. Case-insensitive. Must be a registered provider name (relay, mayan, lifi, cctp, 1inch, jupiter, teleswap, uniswap, deframe, symbiosis-bitcoin). The provider must be eligible for the token pair and chains. When omitted, the API returns and persists the quote with the highest tokenOut.expectedAmountOut. Returns INVALID_PREFERRED_PROVIDER (400) if the name is not registered, PREFERRED_PROVIDER_NOT_ELIGIBLE (400) if the provider does not support the route, or PREFERRED_PROVIDER_QUOTE_UNAVAILABLE (400) if the provider returned no quote. | relay |
slippage | number | Max slippage as a fraction of 1 (e.g. 0.01 = 1%). Range 0.0001–0.5. Passed to the selected provider; omit to use each provider’s default. Returns INVALID_SLIPPAGE (400) when out of range. | 0.01 |
transferSpeed | string | Transfer speed for CCTP cross-chain swaps. fast (default) or standard. Ignored for non-CCTP routes. | fast |
destinationAddress | string | Recipient on the destination chain | 0x… |
refundAddress | string | Refund address if the swap fails | 0x… |
feeSponsorship | boolean | Request fee sponsorship on eligible Deframe bridge routes (deframe provider). Defaults to false. | false |
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)
Same route using chain IDs
Cross-chain with a preferred provider
When several providers can quote the same route, passpreferredProvider to persist and return that provider’s quote (for example, to keep routing consistent with your UI or compliance rules):
Multi-route aggregation
For routes supported by more than one provider, the API requests quotes in parallel, ranks them bytokenOut.expectedAmountOut, and returns a single quote object — the best route by default, or the preferredProvider when set.
- Only that quote is saved to the database. Use the quote
quoteId(or the quote object’sidwhen present) withPOST /v2/swap/bytecode. - Fixed-quote Deframe bridge routes (
deframeprovider) still use a single provider;preferredProvidermust bedeframeor omitted on those paths.
Response Format
The API returns a JSON object with one persisted quote:Response Fields
quoteId
quoteId
Unique identifier for this quote. Use this when executing the swap.
chainIdIn & chainIdOut
chainIdIn & chainIdOut
Canonical numeric chain IDs for the swap route (source → destination). Prefer these for new code; string
originChain / destinationChain and legacy fromChainId / toChainId remain for compatibility.originChain & destinationChain
originChain & destinationChain
Source and destination chain names (e.g.,
ethereum, polygon, arbitrum). These remain supported; numeric chainIdIn / chainIdOut are preferred for new integrations.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, relay, lifi)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
bitcoinHyperEVM
hyperevmError 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
- Invalid or ineligible
preferredProvider(see Error Codes) - Provider-specific errors during quote generation
| Code | When |
|---|---|
INVALID_PREFERRED_PROVIDER | preferredProvider is not a registered provider name |
PREFERRED_PROVIDER_NOT_ELIGIBLE | Provider exists but does not support this chain/token route |
PREFERRED_PROVIDER_QUOTE_UNAVAILABLE | Provider is eligible but did not return a quote (timeout or upstream failure) |
Next Steps
Execute Swap
Use the quote to generate bytecode and execute the swap
API Reference
View detailed API documentation