Crypto order book
GET /api/crypto-orderbookL2 order-book snapshot for a spot pair: best bid/ask, mid price, spread (absolute + %), and the top N aggregated price levels per side (default 25, max 100). Send GET /api/crypto-orderbook with the required field pair and pay $0.001 per call over x402 or MPP (there is no free tier). It returns a JSON object with pair, time, sequence, bestBid, bestAsk and 8 more.
Pairs use BASE-QUOTE format (BTC-USD, ETH-USD, SOL-USDC). Backed by Coinbase Exchange's public market-data API - keyless; coverage is Coinbase-listed markets.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pair | string | yes | Spot pair as BASE-QUOTE (e.g. BTC-USD, ETH-USD, SOL-USDC) |
depth | number | no | Price levels per side to return (1-100, default 25) |
Example request
curl -i "https://agent402.tools/api/crypto-orderbook?pair=BTC-USD"
Without payment this returns HTTP 402 Payment Required with the exact price for crypto-orderbook; any x402 v2 or MPP client pays it and retries.
Example response
{
"pair": "BTC-USD",
"time": "2026-07-14T02:40:51Z",
"sequence": 132601080491,
"bestBid": 62489.29,
"bestAsk": 62490.01,
"midPrice": 62489.65,
"spread": 0.72,
"spreadPct": 0.0012,
"bids": [
{
"price": 62489.29,
"size": 0.81109777,
"orders": 8
}
],
"asks": [
{
"price": 62490.01,
"size": 0.5,
"orders": 3
}
],
"depth": 1,
"totalBidLevels": 15653,
"totalAskLevels": 27473
}
| Field | Type | Always present | In the example |
|---|---|---|---|
pair | string | yes | BTC-USD |
time | string | yes | 2026-07-14T02:40:51Z |
sequence | number | yes | 132601080491 |
bestBid | number | yes | 62489.29 |
bestAsk | number | yes | 62490.01 |
midPrice | number | yes | 62489.65 |
spread | number | yes | 0.72 |
spreadPct | number | yes | 0.0012 |
bids | array of objects | yes | 1 item in the example |
asks | array of objects | yes | 1 item in the example |
depth | number | yes | 1 |
totalBidLevels | number | yes | 15653 |
totalAskLevels | number | yes | 27473 |
From an MCP client
catalog.call {
"slug": "crypto-orderbook",
"params": {
"pair": "BTC-USD"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for crypto-orderbook; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
pairis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - A
POSTwith a JSON body to /api/crypto-orderbook is served as this GET, with the body as the input. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/crypto-orderbook?pair=BTC-USD");
Related tools
Perp order book
POST /api/perp-orderbookLevel-2 order book for one perpetual: best bid/ask, mid, spread (absolute and bps), up to 20 levels per side with size a…
Token price by contract address
GET /api/coin-price-by-contractLive price, market cap, 24h volume and 24h change for ERC-20 / SPL / other chain tokens looked up by CONTRACT ADDRESS on…
Coin profile
GET /api/coin-profileFull profile of one coin by id: name/symbol, description, categories, contract addresses per platform, links (homepage, …
DEX volume by protocol
POST /api/defi-dex-volumeDecentralized exchanges ranked by 24h spot trading volume from DefiLlama's free DEX overview: per-DEX 24h/7d/30d/1y/all-…
Exchange tickers
GET /api/exchange-tickersMarkets (tickers) listed on one exchange: base/target pair, last price, 24h volume, USD- and BTC-converted last price an…
Tokenized asset
GET /api/rwa-assetOne tokenized real-world asset by id (gold, nvidia, tesla, spy ...): identity, type, image and web slug joined with its …