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 |
originAddress | string | Sender address on the origin chain. When provided together with destinationAddress, the response also includes transaction bytecode (id + transactionData) — no separate call to POST /v2/swap/bytecode needed. | 0x… |
transferSpeed | string | Transfer speed for CCTP cross-chain swaps. fast (default) or standard. Ignored for non-CCTP routes. | fast |
originAddress | string | Address of the sender on the origin chain. When provided together with destinationAddress, the endpoint returns transaction bytecode in the same response — no separate call to POST /v2/swap/bytecode is needed. | 0x… |
destinationAddress | string | Recipient on the destination chain. When provided together with originAddress, the endpoint returns transaction bytecode in the same response. | 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. When bothoriginAddress and destinationAddress are supplied, the response also includes transaction bytecode fields (id, chainId, transactionData) — equivalent to calling POST /v2/swap/bytecode separately. The quote always includes a feeBreakdown object that itemizes platform fees (Pods fee, customer markup fee) and the estimated bridge/slippage impact:
Fee breakdown (
feeBreakdown) is returned on GET /v2/swap/quote
only (not on GET /v2/swap/status/:id). Line labels are in English;
localize in your UI. The bridgeAndSlippage line is signed — a negative
amountRaw means favorable price impact vs spot. Platform fees (pods,
customer) are deducted from tokenIn before the provider quote; see
docs/swap-quote-fee-breakdown-spec.md in the API repo.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.
tokenOut.expectedAmountOut and tokenOut.minAmountOut
are the provider guarantees after platform fees are taken from the input.feeBreakdown
feeBreakdown
Itemized costs: Pods fee, Customer fee, and Bridge fee + slippage
(combined, signed on
tokenOut). reference explains the spot baseline used
for the bridge line (source: spotUsdAtQuoteTime or unavailable). Zero
fees use amountRaw "0" and amountInUSD 0.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.
feeBreakdown
feeBreakdown
Itemized cost breakdown for the swap. Always present on quote responses.
chargeableAmountInRaw— Full input amount subject to fees (string, smallest unit).amountInAfterPlatformFeesRaw— Input amount after Pods + customer fees are deducted (string, smallest unit).lines— Array of individual fee lines, each withkind(pods|customer|bridgeAndSlippage),label,amountRaw,decimals,symbol,asset(tokenIn|tokenOut), andamountInUSD.reference— Spot-price reference output used to calculate bridge/slippage impact:amountOutRaw,source(spotUsdAtQuoteTime|unavailable),pricedAt(ISO 8601),tokenInPriceInUSD,tokenOutPriceInUSD,amountInAfterPlatformFeesRaw.summary— Aggregated totals:platformFeesTotalInRaw,platformFeesTotalInUSD,bridgeAndSlippageImpactOutRaw,bridgeAndSlippageImpactOutUSD.
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) |
AMOUNT_IN_TOO_LOW | AmountIn is below the minimum for this route |
AMOUNT_IN_TOO_HIGH | AmountIn exceeds available liquidity for this route. Try a smaller amount. |
Next Steps
Execute Swap
Use the quote to generate bytecode and execute the swap
API Reference
View detailed API documentation