API Documentation

Complete technical reference for the ChainBridge Trading API. Integrate our Smart Order Router, cross-chain swaps, bridge quote API, and price feeds.

Why ChainBridge API?

No API Key Required

Start making requests immediately. No signup, no key management.

3 DEX Aggregators

Compare 0x, KyberSwap and ParaSwap in one call on Ethereum, Arbitrum, Base, Optimism, Polygon, BNB Chain, Avalanche and Linea.

Cross-chain Swaps

EVM to EVM via Relay and LI.FI; EVM to native BTC, LTC, DOGE and BCH via THORChain. Native to EVM is quote only.

Bridge Quote API

Cross-chain routes via LI.FI and Socket (API only).

Gasless Swaps

No gas needed for users on supported pairs via 0x Gasless (all networks except Linea).

Token Safety

GoPlus checks for honeypots, sell taxes and risky token permissions via /api/token-safety.

Transaction Simulation

Simulate the exact transaction via Tenderly before signing (when configured).

ChainBridge vs Alternatives

FeatureChainBridge0x API1inch API
Aggregators compared311
API key requiredNoYesYes
Cross-chain bridge quotesYes (API only)NoNo
Swaps to native BTC/LTC/DOGEYes (THORChain)NoNo
Gasless swapsYesYesYes
Transaction simulationYesNoNo
Embeddable widgetYesNoYes
SSE price streamingYesNoNo
TypeScript SDKYesYesYes

Getting Started

Base URL

https:"color:#5c6370">//www.chainbridge.trading/api

Authentication

Public endpoints (quotes, prices, market data) do not require authentication. Transaction endpoints require a connected wallet and CSRF token. API keys for third-party providers (0x, LI.FI, etc.) are managed server-side and never exposed to clients.

Rate Limiting

All endpoints are rate-limited per IP address. Default limits: 60 req/min for quote endpoints, 20 req/min for swap and gasless endpoints, 30 req/min for bridge endpoints, 100 req/min for prices, and 300 req/min overall. Exceeding limits returns a 429 response with a Retry-After header.

Response Format

All responses are JSON. Error responses follow a consistent format:

{
  "error": "Description of what went wrong",
  "code": "ERROR_CODE",
  "status": 400
}

Smart Order Router (SOR)

Compare and execute swaps across 0x (including 0x Gasless), KyberSwap and ParaSwap. Linea is served by 0x and KyberSwap only. Quotes include the platform fee, reported as feeBps; see the fee schedule.

GET/api/sor/quotes

Fetches quotes from all available DEX aggregators for a given token pair and amount. Returns quotes sorted by best output, including gas estimates and price impact.

Query Parameters

ParameterTypeRequiredDescription
chainIdnumberYesChain ID (1, 42161, 8453, 10, 137, 56, 43114, 59144)
sellTokenstringYesToken address to sell
buyTokenstringYesToken address to buy
sellAmountstringYesAmount in wei (BigInt string)
slippageBpsnumberNoSlippage tolerance in basis points (default: 100 = 1%)
takerAddressstringNoTrader wallet address
curl "https://www.chainbridge.trading/api/sor/quotes?\
  sellToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&\
  buyToken=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&\
  sellAmount=1000000000&\
  chainId=1&\
  takerAddress=0xYourWallet"
POST/api/sor/swap

Generates executable swap quotes. Returns the same envelope as /sor/quotes; the calldata to sign lives in bestQuote.to / bestQuote.data / bestQuote.value / bestQuote.gas.

Request Body

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

Returns the DEX aggregators, whether each is enabled, their supported chains, and features (gasless swaps, fee support).

Cross-chain Swaps

The API behind cross-chain swaps in the swap card. EVM to EVM via Relay and LI.FI; EVM (Ethereum, Base, BNB Chain, Avalanche) to native BTC, LTC, DOGE or BCH via THORChain. Native BTC, LTC, DOGE or BCH to EVM is quote only.

GET/api/crosschain/quote

Quotes every provider in parallel and ranks them by net amount received. Each quote carries the steps to sign (approval included when needed), executable: false for quote-only routes, and any ChainBridge fee as platformFeeBps.

Query Parameters

ParameterTypeRequiredDescription
fromChainId | fromChainnumber | stringYesEVM source chain ID (1, 42161, 8453, 10, 137, 56, 43114, 59144, 324), or BTC, LTC, DOGE, BCH (quote only)
toChainId | toChainnumber | stringYesEVM destination chain ID, or BTC, LTC, DOGE, BCH
fromTokenstringYesSource token address
toTokenstringEVMDestination token address (EVM destinations)
fromTokenDecimalsnumberYesSource token decimals
toTokenDecimalsnumberYesDestination token decimals
amountstringYesAmount in the smallest unit of the source token
fromAddressstringEVMSender wallet (required for EVM sources)
toAddressstringNoRecipient (BTC/LTC/DOGE/BCH address for native destinations)
slippageBpsnumberNoSlippage tolerance in basis points (default: 100)
providersstringNoComma-separated subset of relay, lifi, thorchain
GET/api/crosschain/status

Normalized delivery status of a cross-chain transfer. Params: provider (relay, lifi, thorchain), srcTxHash, fromChainId, plus requestId for Relay and toChain or toChainId for THORChain.

Bridge API

Cross-chain bridge quotes and transactions via LI.FI and Socket. API only; there is no bridge UI.

GET/api/bridge/quote

Fetches cross-chain bridge quotes from all providers. Compares routes by output amount, estimated time, and fees.

Query Parameters

ParameterTypeDescription
fromChainIdnumberSource chain ID
toChainIdnumberDestination chain ID
fromTokenstringSource token address
toTokenstringDestination token address
fromAmountstringAmount in wei
fromAddressstringSender wallet address (required)
curl "https://www.chainbridge.trading/api/bridge/quote?\
  fromChainId=1&\
  toChainId=42161&\
  fromToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&\
  toToken=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&\
  fromAmount=1000000000&\
  fromAddress=0xYourWallet"
POST/api/bridge/transaction

Generates transaction data for a route returned by GET /bridge/quote. Pass the full route object from the quote response; the calldata is returned in data.transaction.

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": "0xYourWallet",
    "slippageBps": 100
  }'
GET/api/bridge/status

Checks bridge transaction status. Returns state (pending, in transit, completed, failed), estimated time, and tx hashes on both chains.

curl "https://www.chainbridge.trading/api/bridge/status?\
  provider=lifi&\
  txHash=0xabc123...def456&\
  fromChainId=1"
GET/api/bridge/chains

Returns supported chains for bridging with metadata (name, chain ID, native token, explorer URL) and available providers per route.

Price API

Real-time token prices powered by CoinGecko.

GET/api/price

Returns current USD prices for specified tokens. Supports multiple addresses in a single request.

Query Parameters

ParameterTypeDescription
tokensstringComma-separated token contract addresses (max 100)
chainIdnumberChain ID (default: 1)
curl "https://www.chainbridge.trading/api/price?\
  chainId=1&\
  tokens=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"

Integration Guide

Prerequisites

  • Node.js 18+ and npm or yarn
  • A WalletConnect Project ID (for wallet connections)
  • A 0x API key
  • In production: CSRF_SECRET (signs CSRF tokens for POST requests)
  • Optional: LI.FI, Socket, CoinGecko, Tenderly keys

Quick Start

"color:#5c6370"># Get a swap quote(no setup needed)
curl "https://www.chainbridge.trading/api/sor/quotes?sellToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&buyToken=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&sellAmount=1000000000&chainId=1"

"color:#5c6370"># Get bridge quote
curl "https://www.chainbridge.trading/api/bridge/quote?fromChainId=1&toChainId=42161&fromToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&toToken=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&fromAmount=1000000000&fromAddress=0xYourWallet"

"color:#5c6370"># Get token price(USD, keyed by lowercased address)
curl "https://www.chainbridge.trading/api/price?chainId=1&tokens=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"