# OneSource Deepstate Order Book API

> OneSource Deepstate Order Book API is a paid API for AI agents from api.onesource.io, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-13).

Retrieves the full live on-chain order book (bids and asks) for a specified Deepstate market, including order details, depth summary, and market session info.

## Facts

- Endpoint: GET https://api.onesource.io/deepstate/v1/book/%7Bbook%7D
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/onesource-deepstate-order-book-api-3a771c23
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_9rWhRDcz4sFtjFgrjxR_n

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability onesource-deepstate-order-book-api-3a771c23
```

Example prompt: Pull the live Deepstate order book for NVDA/USDG — I want to see all current bids and asks, the spread, and the best bid and ask prices right now.

## When to prefer this

Use this endpoint when you need real-time, full-depth on-chain order book data for a Deepstate market — including all resting bid and ask orders, spread, depth, and market session info. Prefer this over general blockchain RPC endpoints when the target is Deepstate market microstructure data rather than raw EVM state. Ideal for AI trading agents, arbitrage monitors, and DeFi analytics pipelines that need structured order book snapshots without parsing raw contract events.

## Known failure modes

- Invalid or unknown book ID/slug returns a 404 or empty result
- Stale data if queried at a block boundary — finality field indicates 'head' vs confirmed
- Payment failure via x402 if USDC balance is insufficient — returns 402 Payment Required
- Network or RPC lag may cause slightly outdated block data
- Malformed book parameter returns a 400 Bad Request

## How this service works

Two data families for AI agents: live Ethereum mainnet, Sepolia testnet, and Robinhood Chain RPC reads, plus Deepstate on-chain market data (order books, trades, candles, and analytics). Pay per call or use batch/session mode: USDC on Base via x402, or pathUSD/USDC.e on Tempo via MPP. No API key required to start; a flat-rate monthly subscription is also available.

## Output

Returns a JSON object containing two arrays — bids and asks — each with individual order details (price, size, maker address, order ID, queue position, block rested), plus a summary object with best bid/ask, mid price, spread in bps, order count, market depth (quote value), last trade price, market session, block number, block hash, and base/quote token metadata.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "properties": {
   "type": "string"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "asks": [
   {
    "side": "ask",
    "size": 32945.18,
    "maker": "0x7C3e9F1a5B2d4E68A091c3D5b7F20e846A1c9D3f",
    "price": 220.47924566,
    "order_id": "0x2ac5822b00000000000000000000000000000007abaf8d6000000000fffbb08b",
    "size_raw": "32945180000",
    "nonce_raw": 4294684811,
    "price_raw": "220.47924566",
    "rest_index": 282484,
    "sequence_raw": "4294684811",
    "is_bid_token0": true,
    "price_key_raw": "0x2ac5822b",
    "queue_position": 0,
    "rested_at_block": 52685011
   }
  ],
  "bids": [
   {
    "side": "bid",
    "size": 3263.516552,
    "maker": "0x884a1B2c3D4e5F60718293a4B5c6D7e8F90A1b2C",
    "price": 216.48219249,
    "order_id": "0x2ace848e00000000000000000000000000000000c2854f8800000000fffbb024",
    "size_raw": "3263516552",
    "nonce_raw": 4294684708,
    "price_raw": "216.48219249",
    "rest_index": 282587,
    "sequence_raw": "4294684708",
    "is_bid_token0": false,
    "price_key_raw": "0x2ace848e",
    "queue_position": 0,
    "rested_at_block": 52685102
   }
  ],
  "book_id": "0xdf941c235503a5d2e67aee5dea00f2965f99421c0d034bd77f924c05c66bf399",
  "summary": {
   "book_id": "0xdf941c235503a5d2e67aee5dea00f2965f99421c0d034bd77f924c05c66bf399",
   "mid_raw": "218.48071908",
   "finality": "head",
   "ask_count": 208,
   "bid_count": 45,
   "book_label": "NVDA/USDG",
   "spread_bps": 182.9476,
   "spread_raw": "3.99705317",
   "order_count": 253,
   "best_ask_raw": "220.47924566",
   "best_bid_raw": "216.48219249",
   "block_number": 52685677,
   "top_ask_maker": "0x7C3e9F1a5B2d4E68A091c3D5b7F20e846A1c9D3f",
   "top_bid_maker": "0x884a1B2c3D4e5F60718293a4B5c6D7e8F90A1b2C",
   "market_session": "regular",
   "top_ask_order_id": "0x2ac5822b00000000000000000000000000000007abaf8d6000000000fffbb08b",
   "top_bid_order_id": "0x2ace848e00000000000000000000000000000000c2854f8800000000fffbb024",
   "ask_depth_quote_raw": "6910233187",
   "bid_depth_quote_raw": "1284770412",
   "base_fee_per_gas_raw": "485000000",
   "last_trade_price_raw": "216.48",
   "ask_depth_1pct_quote_raw": "6910233187",
   "bid_depth_1pct_quote_raw": "1284770412"
  },
  "finality": "head",
  "book_slug": "NVDA-USDG",
  "base_token": {
   "symbol": "NVDA",
   "address": "0xd0601CE157Db5bdC3162BbaC2a2C8aF5320D9EEC",
   "decimals": 18
  },
  "block_hash": "0x9f2b1c0d4e7a5b83c61f0d2a4e8b7c95d3a1f6e08b2c4d7a9e5f31b0c8d2a4e6",
  "book_label": "NVDA/USDG",
  "quote_token": {
   "symbol": "USDG",
   "address": "0x5fc5360D0
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/onesource-deepstate-order-book-api-3a771c23/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.onesource.io](https://www.zero.xyz/host/api.onesource.io/llms.txt)
