> For the complete documentation index, see [llms.txt](https://pacifica.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pacifica.gitbook.io/docs/api-documentation/api/websocket/subscriptions/orderbook.md).

# Orderbook

Refer to [Websocket](/docs/api-documentation/api/websocket.md) for establishing the websocket connection.

### Params

```json
{
    "method": "subscribe",
    "params": {
        "source": "book",
        "symbol": "SOL",
        "agg_level": 1  // Aggregation level
    }
}
```

where `agg_level`can be one of `1, 10, 100, 1000, 10000`.

### Stream

```json
{
  "channel": "book",
  "data": {
    "l": [
      [
        {
          "a": "37.86",
          "n": 4,
          "p": "157.47"
        },
        // ... other aggegated bid levels
      ],
      [
        {
          "a": "12.7",
          "n": 2,
          "p": "157.49"
        },
        {
          "a": "44.45",
          "n": 3,
          "p": "157.5"
        },
        // ... other aggregated ask levels
      ]
    ],
    "s": "SOL",
    "t": 1749051881187,
    "li": 1559885104
  }
}
```

The `book` websocket stream updates once every 250ms

| Field  | Type           | Description                                                                                                                                   |
| ------ | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `'l'`  | array          | \[Bids, Asks]                                                                                                                                 |
| `'a'`  | decimal string | Total amount in aggregation level.                                                                                                            |
| `'n'`  | integer        | Number of orders in aggregation level.                                                                                                        |
| `'p'`  | decimal string | <ul><li>In bids array, this is highest price in aggregation level.</li><li>In asks array, this is lowest price is aggregation level</li></ul> |
| `'s'`  | string         | Symbol                                                                                                                                        |
| `'t'`  | number         | Timestamp in milliseconds                                                                                                                     |
| `'li'` | number         | Exchange-wide nonce. Used to reliably determine exchange event ordering. Sequential and not subject to clock drift.                           |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pacifica.gitbook.io/docs/api-documentation/api/websocket/subscriptions/orderbook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
