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

# l2Book: Fetch Full L2 Order Book Snapshot via REST

> Pull a one-time full L2 order book snapshot with all price levels for a contract. For live updates, use the WebSocket l2Book channel instead.

The `l2Book` query returns a full L2 order book snapshot containing all price levels for a contract at a point in time. This is useful for initializing local order book state before connecting to the WebSocket feed. For ongoing updates, subscribe to the WebSocket `l2Book` channel — subscribing automatically delivers an initial snapshot, so you typically do not need to make this REST call separately.

<Warning>
  This endpoint returns HTTP 503 with a `NOT_READY` error if no book data exists yet (for example, on a cold start or if no orders have ever been placed on the contract). Implement retry logic with exponential backoff when you receive this response.
</Warning>

## Request

```json theme={"system"}
{"type": "l2Book", "asset": "1"}
```

<ParamField body="type" type="string" required>
  Must be `"l2Book"`.
</ParamField>

<ParamField body="asset" type="string" required>
  The contract ID to fetch the order book for, expressed as a decimal string (e.g. `"1"`). Use the `contractId` from `configs`.
</ParamField>

## Response

```json theme={"system"}
{
  "asset": "1",
  "time": 1782270780000,
  "bookVersion": 90231,
  "markPx": "100",
  "oraclePx": "100",
  "levels": [
    [{"px": "100", "sz": "5", "n": 3}],
    [{"px": "101", "sz": "2", "n": 1}]
  ]
}
```

<ResponseField name="asset" type="string">
  Contract ID.
</ResponseField>

<ResponseField name="time" type="integer">
  Timestamp of the snapshot in Unix milliseconds.
</ResponseField>

<ResponseField name="bookVersion" type="integer">
  Monotonically increasing version number for this book. Use this to deduplicate or order updates when combining REST snapshots with WebSocket deltas.
</ResponseField>

<ResponseField name="markPx" type="string">
  Current mark price (raw integer string). Returns `"0"` if the mark price has not yet been published for this contract.
</ResponseField>

<ResponseField name="oraclePx" type="string">
  Current oracle (index) price (raw integer string). Returns `"0"` if the oracle price has not yet been published for this contract.
</ResponseField>

<ResponseField name="levels" type="array[]">
  Two-element array: `levels[0]` contains bids sorted from highest to lowest price; `levels[1]` contains asks sorted from lowest to highest price.

  <Expandable title="Price level fields">
    <ResponseField name="px" type="string">
      Price at this level (raw integer string). Divide by `10^priceScale` from `configs` to get the display value.
    </ResponseField>

    <ResponseField name="sz" type="string">
      Total quantity available at this price level (raw integer string). Divide by `10^qtyScale` from `configs` to get the display value.
    </ResponseField>

    <ResponseField name="n" type="integer">
      Number of individual orders resting at this price level.
    </ResponseField>
  </Expandable>
</ResponseField>
