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
| Feature | ChainBridge | 0x API | 1inch API |
|---|---|---|---|
| Aggregators compared | 3 | 1 | 1 |
| API key required | No | Yes | Yes |
| Cross-chain bridge quotes | Yes (API only) | No | No |
| Swaps to native BTC/LTC/DOGE | Yes (THORChain) | No | No |
| Gasless swaps | Yes | Yes | Yes |
| Transaction simulation | Yes | No | No |
| Embeddable widget | Yes | No | Yes |
| SSE price streaming | Yes | No | No |
| TypeScript SDK | Yes | Yes | Yes |
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.
/api/sor/quotesFetches 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
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID (1, 42161, 8453, 10, 137, 56, 43114, 59144) |
sellToken | string | Yes | Token address to sell |
buyToken | string | Yes | Token address to buy |
sellAmount | string | Yes | Amount in wei (BigInt string) |
slippageBps | number | No | Slippage tolerance in basis points (default: 100 = 1%) |
takerAddress | string | No | Trader wallet address |
curl "https://www.chainbridge.trading/api/sor/quotes?\ sellToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&\ buyToken=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&\ sellAmount=1000000000&\ chainId=1&\ takerAddress=0xYourWallet"
/api/sor/swapGenerates 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 }'
/api/sor/aggregatorsReturns 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.
/api/crosschain/quoteQuotes 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
| Parameter | Type | Required | Description |
|---|---|---|---|
fromChainId | fromChain | number | string | Yes | EVM source chain ID (1, 42161, 8453, 10, 137, 56, 43114, 59144, 324), or BTC, LTC, DOGE, BCH (quote only) |
toChainId | toChain | number | string | Yes | EVM destination chain ID, or BTC, LTC, DOGE, BCH |
fromToken | string | Yes | Source token address |
toToken | string | EVM | Destination token address (EVM destinations) |
fromTokenDecimals | number | Yes | Source token decimals |
toTokenDecimals | number | Yes | Destination token decimals |
amount | string | Yes | Amount in the smallest unit of the source token |
fromAddress | string | EVM | Sender wallet (required for EVM sources) |
toAddress | string | No | Recipient (BTC/LTC/DOGE/BCH address for native destinations) |
slippageBps | number | No | Slippage tolerance in basis points (default: 100) |
providers | string | No | Comma-separated subset of relay, lifi, thorchain |
/api/crosschain/statusNormalized 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.
/api/bridge/quoteFetches cross-chain bridge quotes from all providers. Compares routes by output amount, estimated time, and fees.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
fromChainId | number | Source chain ID |
toChainId | number | Destination chain ID |
fromToken | string | Source token address |
toToken | string | Destination token address |
fromAmount | string | Amount in wei |
fromAddress | string | Sender wallet address (required) |
curl "https://www.chainbridge.trading/api/bridge/quote?\ fromChainId=1&\ toChainId=42161&\ fromToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&\ toToken=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&\ fromAmount=1000000000&\ fromAddress=0xYourWallet"
/api/bridge/transactionGenerates 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 }'
/api/bridge/statusChecks 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"
/api/bridge/chainsReturns 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.
/api/priceReturns current USD prices for specified tokens. Supports multiple addresses in a single request.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
tokens | string | Comma-separated token contract addresses (max 100) |
chainId | number | Chain 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"