> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trusset.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Order Book Snapshot

> Read current depth, last price, and the 24-hour tape

Returns a point-in-time view of one book: aggregated depth on both sides, the last traded price, the live price reference where one is configured, and rolling 24-hour statistics.

When the book pools depth with other books in its fungibility class, all four widen to the whole eligible set, so the depth you see is the depth an order would actually reach.

Depth counts only orders that can be hit: `OPEN` or `PARTIALLY_FILLED`, not past their expiry, and backed by a balance lock. A depth read that fails returns empty sides rather than an error.

## Path Parameters

<ParamField path="orderBookId" type="string" required>Order book ID.</ParamField>

## Query Parameters

<ParamField query="levels" type="integer" default="20">Price levels per side, capped at 100.</ParamField>

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="orderBook" type="object">
      Trading rules that apply to an order right now: `id`, `tokenAddress`, `quoteTokenAddress`, `name`, `symbol`, `status`, `tokenType`, `settlementMode`, `custodyContract`, `allowImport`, `priceRefEnabled`, `makerFeeBps`, `takerFeeBps`, `minOrderSize`, `maxOrderSize` and `tickSize`.
    </ResponseField>

    <ResponseField name="depth" type="object">
      <Expandable>
        <ResponseField name="bids" type="array">Buy levels, highest price first. Each carries `price`, `quantity` and `orderCount`.</ResponseField>
        <ResponseField name="asks" type="array">Sell levels, lowest price first. Each carries `price`, `quantity` and `orderCount`.</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="lastPrice" type="string">Price of the most recent trade in order book units, or `null`.</ResponseField>

    <ResponseField name="priceReference" type="object">
      Live reference state, or `null`. Carries `price`, `mode`, `enforcement`, `spreadBps`, `lowerBound`, `upperBound` and `lastUpdated`.
    </ResponseField>

    <ResponseField name="stats24h" type="object">
      <Expandable>
        <ResponseField name="volume" type="string">Base volume over 24 hours, in order book units.</ResponseField>
        <ResponseField name="trades" type="integer">Trade count over 24 hours.</ResponseField>
        <ResponseField name="high" type="string">Highest trade price, or `null`.</ResponseField>
        <ResponseField name="low" type="string">Lowest trade price, or `null`.</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="timestamp" type="string">When the snapshot was taken.</ResponseField>
  </Expandable>
</ResponseField>

<Note>
  Trades whose settlement failed permanently are excluded from `lastPrice` and `stats24h`. A refused settlement moved nothing and was reversed, so counting it would misstate the tape.
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.trusset.org/orderbooks/commodities/api/order-books/clx_ob_comm_001/snapshot?levels=10" \
    -H "X-API-Key: trusset_your_key_here"
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch(
    `https://api.trusset.org/orderbooks/commodities/api/order-books/${orderBookId}/snapshot?levels=10`,
    { headers: { 'X-API-Key': 'trusset_your_key_here' } }
  );
  const { data } = await res.json();
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "orderBook": {
        "id": "clx_ob_comm_001",
        "tokenAddress": "0xd8f3ba9de5b7b83f66d1a7b1ad96c1a64b811ff9",
        "quoteTokenAddress": "0x98ad0ca091552e23c564b41c74282e5343d03e8a",
        "name": "Allocated Gold 999.9",
        "symbol": "XAUA",
        "status": "ACTIVE",
        "tokenType": "LIGHT_TOKEN",
        "settlementMode": "ON_CHAIN",
        "custodyContract": "0xf3dac9cf19da1c95a80de890e200bc86e0c6f2da",
        "allowImport": true,
        "priceRefEnabled": true,
        "makerFeeBps": 2,
        "takerFeeBps": 8,
        "minOrderSize": "1000000",
        "maxOrderSize": null,
        "tickSize": "10000"
      },
      "depth": {
        "bids": [{ "price": "2410000000", "quantity": "3000000", "orderCount": 2 }],
        "asks": [{ "price": "2415000000", "quantity": "5000000", "orderCount": 3 }]
      },
      "lastPrice": "2412550000",
      "priceReference": {
        "price": "2412.55",
        "mode": "EXTERNAL_FEED",
        "enforcement": "1MIN",
        "spreadBps": 100,
        "lowerBound": "2388.4245",
        "upperBound": "2436.6755",
        "lastUpdated": "2025-06-15T11:59:30.000Z"
      },
      "stats24h": { "volume": "18000000", "trades": 9, "high": "2418000000", "low": "2405000000" },
      "timestamp": "2025-06-15T12:00:00.000Z"
    }
  }
  ```
</ResponseExample>

## Error Codes

| Code                   | HTTP  | Cause                                                     |
| ---------------------- | ----- | --------------------------------------------------------- |
| `ORDER_BOOK_NOT_FOUND` | `404` | No such commodity book on this instance, and not imported |
| `SERVICE_NOT_ENABLED`  | `403` | The Trading service is not enabled on this instance       |
