Developer Tools

Integrate ChainBridge into your application. Access 7 DEX aggregators, cross-chain bridges, and real-time pricing through a unified API.

Base URL: https://www.chainbridge.trading/apiRate Limit: 30 req/minFormat: JSON

API Reference

All endpoints return JSON. Errors follow the format { "error": "message" } with appropriate HTTP status codes.

GET/api/sor/quotes

Query the Smart Order Router for quotes across all 7 aggregators (0x, 1inch, ParaSwap, KyberSwap, UniswapX, Balancer V3, Thorchain). Returns the best quote and all individual aggregator quotes for comparison.

Parameters

ParameterTypeRequiredDescription
sellTokenstringYesAddress of the token to sell (0x-prefixed)
buyTokenstringYesAddress of the token to buy (0x-prefixed)
sellAmountstringYesAmount to sell in base units (wei)
chainIdnumberYesChain ID (1, 10, 8453, 42161)
slippageBpsnumberNoSlippage tolerance in basis points (default: 100 = 1%)
takerAddressstringNoAddress of the taker (for gasless quotes)

Example Request

bash
curl -X GET "https://www.chainbridge.trading/api/sor/quotes?sellToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&buyToken=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&sellAmount=1000000000&chainId=1&slippageBps=100" \
  -H "Content-Type: application/json"

Example Response

json
{
  "success": true,
  "data": {
    "request": {
      "chainId": 1,
      "sellToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "buyToken": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
      "sellAmount": "1000000000",
      "slippageBps": 100
    },
    "quotes": [
      {
        "aggregator": "0x",
        "buyAmount": "432156789012345678",
        "buyAmountMin": "427835221111111111",
        "price": "0.000432",
        "priceImpact": 0.12,
        "gas": "145000",
        "sources": [{ "name": "Uniswap_V3", "proportion": 1 }]
      },
      {
        "aggregator": "1inch",
        "buyAmount": "431987654321098765",
        "buyAmountMin": "427667777777777777",
        "price": "0.000431",
        "gas": "152000"
      }
    ],
    "bestQuote": {
      "aggregator": "0x",
      "sellToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "buyToken": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
      "sellAmount": "1000000000",
      "buyAmount": "432156789012345678",
      "buyAmountMin": "427835221111111111",
      "price": "0.000432",
      "priceImpact": 0.12,
      "gas": "145000",
      "gasCostUSD": "3.25",
      "sources": [{ "name": "Uniswap_V3", "proportion": 1 }]
    },
    "stats": {
      "totalAggregators": 7,
      "successfulQuotes": 5,
      "timestamp": 1742900000000
    }
  }
}
POST/api/sor/swap

Build a swap transaction. Returns the same envelope as /sor/quotes, with executable calldata in bestQuote.to / bestQuote.data / bestQuote.value / bestQuote.gas, ready to sign and broadcast from the user's wallet.

Parameters

ParameterTypeRequiredDescription
preferredAggregatorstringNoAggregator to try first (0x, 1inch, paraswap, kyber, uniswapx, balancer, thorchain)
sellTokenstringYesToken to sell address
buyTokenstringYesToken to buy address
sellAmountstringYesAmount in base units
chainIdnumberYesChain ID
takerAddressstringYesUser wallet address
slippageBpsnumberNoSlippage in basis points

Example Request

bash
curl -X POST "https://www.chainbridge.trading/api/sor/swap" \
  -H "Content-Type: application/json" \
  -d '{
    "preferredAggregator": "0x",
    "sellToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "buyToken": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "sellAmount": "1000000000",
    "chainId": 1,
    "takerAddress": "0xYourWalletAddress",
    "slippageBps": 100
  }'

Example Response

json
{
  "success": true,
  "data": {
    "request": {
      "chainId": 1,
      "sellToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "buyToken": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
      "sellAmount": "1000000000",
      "takerAddress": "0xYourWalletAddress",
      "slippageBps": 100
    },
    "quotes": [
      {
        "aggregator": "0x",
        "buyAmount": "432156789012345678",
        "buyAmountMin": "427835221111111111",
        "price": "0.000432",
        "gas": "250000"
      }
    ],
    "bestQuote": {
      "aggregator": "0x",
      "buyAmount": "432156789012345678",
      "buyAmountMin": "427835221111111111",
      "price": "0.000432",
      "gas": "250000",
      "to": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF",
      "data": "0xd9627aa4000000000000000...",
      "value": "0",
      "allowanceTarget": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
    },
    "stats": {
      "totalAggregators": 1,
      "successfulQuotes": 1,
      "timestamp": 1742900000000
    }
  }
}
GET/api/bridge/quote

Get cross-chain bridge quotes from multiple providers (LI.FI, Socket, SwapKit). Compares routes across 7 supported chains.

Parameters

ParameterTypeRequiredDescription
fromChainIdnumberYesSource chain ID
toChainIdnumberYesDestination chain ID
fromTokenstringYesSource token address
toTokenstringYesDestination token address
fromAmountstringYesAmount in base units
fromAddressstringYesSender wallet address

Example Request

bash
curl -X GET "https://www.chainbridge.trading/api/bridge/quote?fromChainId=1&toChainId=42161&fromToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&toToken=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&fromAmount=1000000000&fromAddress=0xYourWallet" \
  -H "Content-Type: application/json"

Example Response

json
{
  "success": true,
  "data": {
    "request": {
      "fromChainId": 1,
      "toChainId": 42161,
      "fromToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "toToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
      "fromAmount": "1000000000",
      "fromAddress": "0xYourWallet",
      "slippageBps": 100
    },
    "routes": [
      {
        "id": "lifi-route-1",
        "provider": "lifi",
        "bridgeUsed": "stargate",
        "fromChainId": 1,
        "toChainId": 42161,
        "fromAmount": "1000000000",
        "toAmount": "998500000",
        "toAmountMin": "988515000",
        "estimatedTime": 120,
        "gasCostUSD": "3.20",
        "totalFeeUSD": "0.50",
        "steps": [],
        "tags": ["FASTEST", "CHEAPEST"]
      }
    ],
    "bestRoute": {
      "id": "lifi-route-1",
      "provider": "lifi",
      "bridgeUsed": "stargate",
      "toAmount": "998500000",
      "toAmountMin": "988515000",
      "estimatedTime": 120,
      "gasCostUSD": "3.20",
      "totalFeeUSD": "0.50"
    },
    "routesByProvider": {
      "lifi": [{ "id": "lifi-route-1", "provider": "lifi", "toAmount": "998500000" }]
    },
    "stats": {
      "totalRoutes": 1,
      "timestamp": 1742900000000
    }
  }
}
POST/api/bridge/transaction

Build a bridge transaction for a route returned by GET /bridge/quote. Pass the full route object from the quote response. Returns calldata for the user to sign.

Parameters

ParameterTypeRequiredDescription
routeobjectYesRoute object returned by GET /bridge/quote (routes[] or bestRoute)
fromAddressstringYesSender wallet address
toAddressstringNoReceiver address (defaults to fromAddress)
slippageBpsnumberNoSlippage in basis points (default: 100)

Example Request

bash
curl -X POST "https://www.chainbridge.trading/api/bridge/transaction" \
  -H "Content-Type: application/json" \
  -d '{
    "route": {
      "id": "lifi-route-1",
      "provider": "lifi",
      "bridgeUsed": "stargate",
      "fromChainId": 1,
      "toChainId": 42161
    },
    "fromAddress": "0xYourWalletAddress",
    "slippageBps": 100
  }'

Example Response

json
{
  "success": true,
  "data": {
    "transaction": {
      "to": "0x1231DEB6f5749ef6cE6943a275A1D3E7486F4EaE",
      "data": "0x4630a0d8000000...",
      "value": "0",
      "gasLimit": "350000",
      "chainId": 1
    },
    "route": {
      "id": "lifi-route-1",
      "provider": "lifi",
      "bridgeUsed": "stargate",
      "fromChainId": 1,
      "toChainId": 42161
    }
  }
}
GET/api/price

Get real-time USD token prices from CoinGecko. Pass token contract addresses; prices are keyed by lowercased address and are null when unknown.

Parameters

ParameterTypeRequiredDescription
tokensstringYesComma-separated token contract addresses (max 100)
chainIdnumberNoChain ID (default: 1)

Example Request

bash
curl -X GET "https://www.chainbridge.trading/api/price?chainId=1&tokens=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" \
  -H "Content-Type: application/json"

Example Response

json
{
  "success": true,
  "data": {
    "chainId": 1,
    "prices": {
      "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2": 3456.78,
      "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": 1.0001
    },
    "timestamp": 1742900000000
  }
}
GET/api/health

Health check endpoint. Returns service status and version information.

Example Request

bash
curl -X GET "https://www.chainbridge.trading/api/health"

Example Response

json
{
  "status": "healthy",
  "timestamp": "2026-03-25T12:00:00.000Z",
  "version": "0.1.0",
  "uptime": 86400,
  "checks": {
    "zerox": true,
    "coingecko": true
  }
}

Widget Integration

Embed the ChainBridge swap widget directly into your website. The widget provides a fully functional token swap interface with access to all 7 aggregators, powered by the same Smart Order Router as the main application.

Embed Code

Add this snippet to your HTML to embed the swap widget. Customize the default chain and tokens via query parameters.

html
<style="color:#e06c75">iframe
  src=style="color:#98c379">"https:style="color:#5c6370style="color:#98c379">">//www.chainbridge.trading/embed?chainId=style="color:#d19a66">1&sellToken=USDC&buyToken=ETH"
  width=style="color:#98c379">"style="color:#d19a66">420"
  height=style="color:#98c379">"style="color:#d19a66">540"
  frameborder=style="color:#98c379">"style="color:#d19a66">0"
  style=style="color:#98c379">"border-radius: 16px; border: 1px solid #e5e7eb;"
  allow=style="color:#98c379">"clipboard-write"
  title=style="color:#98c379">"ChainBridge Swap Widget"
></style="color:#e06c75">iframe>
Query parameters:
  • chainId -- Default chain (1, 10, 8453, 42161)
  • sellToken -- Default sell token symbol
  • buyToken -- Default buy token symbol
  • theme -- Widget theme (light, dark)

SDKComing Soon

The @chainbridge/sdk package will provide a typed TypeScript client for all ChainBridge APIs. Install via npm and start building in minutes.

bash
npm install @chainbridge/sdk

Planned API

typescript
import { ChainBridge } from '@chainbridge/sdk'

const cb = new ChainBridge() "color:#5c6370">// no API key required

"color:#5c6370">// Get best quote across 7 aggregators
const { bestQuote } = await cb.getQuote({
  sellToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', "color:#5c6370">// USDC
  buyToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',  "color:#5c6370">// WETH
  sellAmount: '1000000000',
  chainId: 1,
})

"color:#5c6370">// Build swap transaction(to, data, value, gas)
const tx = await cb.getSwapTransaction({
  sellToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  buyToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
  sellAmount: '1000000000',
  chainId: 1,
  takerAddress: '0xYourWallet',
  slippageBps: 100,
})

"color:#5c6370">// Bridge tokens cross-chain
const { bestRoute } = await cb.getBridgeQuote({
  fromChainId: 1,
  toChainId: 42161,
  fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  toToken: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
  fromAmount: '1000000000',
  fromAddress: '0xYourWallet',
})

"color:#5c6370">// Get real-time USD prices(keyed by lowercased address)
const { prices } = await cb.getPrice({
  chainId: 1,
  tokens: ['0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'],
})

Want early access? Join the waitlist by reaching out on Discord or Telegram.