Skip to main content
In this section, you’ll learn how to request quotes for swapping between tokens using the Deframe API.

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 header

Overview

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 destinationChain

Getting a Quote

Endpoint

GET /swap/quote

Required Parameters

ParameterTypeDescriptionExample
originChainstringSource chain nameethereum, polygon, arbitrum
tokenInstringContract address of input token0xdAC17F958D2ee523a2206206994597C13D831ec7 (USDT)
amountInstringAmount of input tokens to swap1000000 (1 USDT with 6 decimals)
amountOutstringExact output amount (alternative to amountIn)998500
destinationChainstringTarget chain namepolygon, ethereum, base
tokenOutstringContract address of output token0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 (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)

curl --request GET \
  --url 'https://api.deframe.io/swap/quote?originChain=ethereum&destinationChain=ethereum&tokenIn=0xdAC17F958D2ee523a2206206994597C13D831ec7&tokenOut=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&amountIn=1000000' \
  --header 'x-api-key: YOUR_API_KEY'

Cross-Chain Swap (Ethereum to Polygon)

curl --request GET \
  --url 'https://api.deframe.io/swap/quote?originChain=ethereum&destinationChain=polygon&tokenIn=0xdAC17F958D2ee523a2206206994597C13D831ec7&tokenOut=0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174&amountIn=1000000' \
  --header 'x-api-key: YOUR_API_KEY'

Response Format

The API returns a JSON object containing the quote details:
{
  "quote": {
    "quoteId": "550e8400-e29b-41d4-a716-446655440000",
    "originChain": "ethereum",
    "destinationChain": "polygon",
    "tokenIn": {
      "contract": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
      "symbol": "USDT",
      "decimals": 6,
      "amount": "1000000",
      "chainId": 1
    },
    "tokenOut": {
      "contract": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
      "symbol": "USDC",
      "decimals": 6,
      "amount": "998500",
      "chainId": 137
    },
    "provider": "TeleSwap",
    "deadline": "2024-01-24T12:35:00.000Z",
    "rawQuote": {
      // Provider-specific quote data
    }
  }
}

Response Fields

Unique identifier for this quote. Use this when executing the swap.
Source and destination chain names (e.g., ethereum, polygon, arbitrum)
Complete token information including contract address, symbol, decimals, amount, and chain ID
Name of the swap provider used (e.g., 1inch, Jupiter, TeleSwap, Mayan)
Quote expiration timestamp. Execute the swap before this time.
Provider-specific quote data. Pass this to the bytecode endpoint.

Supported Chains

Ethereum

ethereum
https://mintcdn.com/pods-322144f0/7jezKt0SVoazZ1ma/images/networks/base.svg?fit=max&auto=format&n=7jezKt0SVoazZ1ma&q=85&s=15bb56757a1286150e3c5f3e07b75e19

Base

base
https://mintcdn.com/pods-322144f0/7jezKt0SVoazZ1ma/images/networks/optimism.svg?fit=max&auto=format&n=7jezKt0SVoazZ1ma&q=85&s=e917afb4f16fb22fc83b3451ec452f04

Optimism

optimism
https://mintcdn.com/pods-322144f0/7jezKt0SVoazZ1ma/images/networks/arbitrum.svg?fit=max&auto=format&n=7jezKt0SVoazZ1ma&q=85&s=68a6dea21de8efb21fada4315d2bf662

Arbitrum

arbitrum
https://mintlify.s3.us-west-1.amazonaws.com/pods-322144f0/images/networks/solana.svg

Solana

solana
https://mintcdn.com/pods-322144f0/7jezKt0SVoazZ1ma/images/networks/polygon.svg?fit=max&auto=format&n=7jezKt0SVoazZ1ma&q=85&s=11f5769cf45ce3efc3ab9543f71cc7e2

Polygon

polygon
https://mintcdn.com/pods-322144f0/7jezKt0SVoazZ1ma/images/networks/gnosis.svg?fit=max&auto=format&n=7jezKt0SVoazZ1ma&q=85&s=5ed35e443ffa1bdd2137827079deb7d0

Gnosis

gnosis
https://mintlify.s3.us-west-1.amazonaws.com/pods-322144f0/images/networks/bitcoin.svg

Bitcoin

bitcoin

Error 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
Example Error Response:
{
  "error": "No provider available for cross-chain swap from ethereum to unsupported-chain"
}
Quotes have an expiration time (typically 5 minutes). Make sure to execute the swap before the deadline timestamp.

Next Steps