Base URL
Use this REST API for BaiBai integrations.
Rules
- Base only for now:
chainId: 8453. - Gasless EIP-712 orders only.
- Traditional/non-gasless orders are coming soon.
- Amounts are token base units as decimal strings.
- Use ERC-20 tokens with Permit2.
- Native ETH is not a gasless order token. Use WETH in quote and order requests; callers handle wrap/unwrap transactions.
0x4200000000000000000000000000000000000006
Endpoints
List Tokens
GET /tokens?chainId=8453
/quote.
Quote
POST /quote
Request
For exact-output quotes, use
kind: "buy" and buyAmountAfterFee.
Response
Approve
permit2.allowanceTarget, not permit2.spender. spender is included in the EIP-712 signature.Quote Expiry
Before signing, verify the quote is still fresh:Quote Controls
routingPreference is optional:
Examples:
auto for best execution unless your integration intentionally wants to bias routing.
Submit Order
POST /orders
Request
If a request with the same
clientOrderId was already accepted for the same owner, BaiBai returns the existing order instead of creating a duplicate. Use the same clientOrderId when retrying after network failures.
Response
Get Order
GET /orders/{orderId}
Poll every 1-2 seconds, then back off to every 5 seconds for longer-running orders.
Native ETH
Use WETH in quote and order requests.Swapping from ETH
Request an indicative WETH quote before the user wraps:Swapping to ETH
Quote WETH as the buy token, submit the order, then unwrap WETH after the order fills.Rate Limits
Rate-limited responses use HTTP429 and include these headers:
Errors
Errors use this envelope:
Examples:
cURL Happy Path
OpenAPI
Download OpenAPI
Related Docs
Aggregator Flow
Quote, sign, submit, status, routing, and retry concepts.
Wallet Integration
Wallet-side Permit2, signing, polling, and ETH/WETH examples.
BaiBai Overview
Product overview and architecture.