Skip to main content

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.
Base WETH: 0x4200000000000000000000000000000000000006

Endpoints

List Tokens

GET /tokens?chainId=8453
Use token decimals to convert user-facing amounts into base units before calling /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:
If the quote is expired or close to expiry, request a fresh quote. This matters when the user must wrap ETH, send an approval transaction, or takes time to confirm a signature.

Quote Controls

routingPreference is optional: Examples:
Use 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:
Then wrap ETH to WETH, approve Permit2, check quote expiry, sign, and submit. If wrapping or approval takes too long, request a fresh WETH quote.

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 HTTP 429 and include these headers:

Errors

Errors use this envelope:
Common HTTP statuses: Examples:

cURL Happy Path

OpenAPI

Download OpenAPI

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.