# Orderbook

The order-book channel generates a book event when a order is added, updated, deleted from the orderbook.

{% hint style="info" %}
When subscribing, the `pair` should be set in **alphanumeric format only**. Do not use separators between the base and quote asset. The correct format for NIZA/USDT to be set in a channel name is `NIZAUSDT`.
{% endhint %}

### Subscribe with Pusher

```javascript
var channel = pusher.subscribe("order-book.{pair}");
```

### Subscribe Request Payload

```javascript
{
   "event": "pusher:subscribe",
   "data": {
       "channel": "order-book.{pair}"
   }
}
```

### Examples

<details>

<summary>Pusher</summary>

```javascript
var channel = pusher.subscribe("order-book.NIZAUSDT");
```

</details>

<details>

<summary>WebSocket API in Javascript</summary>

```javascript
const message = {
        event: "pusher:subscribe",
        data: {
            channel: "order-book.NIZAUSDT"
        }
    };
socket.send(JSON.stringify(message));
```

</details>

### Payload

| Name            | Type    | Description                                            |
| --------------- | ------- | ------------------------------------------------------ |
| channel         | string  | The name of the channel                                |
| type            | string  | Type of the event                                      |
| data            | array   | The payload of trade data                              |
| data.asks       | string  | Sell order data. Empty array if order side is Buy      |
| data.asks.price | decimal | Order price                                            |
| data.asks.qty   | decimal | Order volume                                           |
| data.bids       | object  | Buy order data. Empty array if the order side is sell. |
| data.bids.price | decimal | Order price                                            |
| data.bids.qty   | decimal | Order Volume                                           |
| data.symbol     | string  | Example: "NIZA/USDT" The symbol of the currency pair.  |

### Example of the Payload

```json
{
    "channel":"book",
    "type":"update",
    "data":{
        "asks":[],
        "bids":{
            "price":"0.00013180",
            "qty":"854921.09000000"
        },
        "symbol":"NIZA/USDT"
    }
}
```


---

# Agent Instructions: 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://docs.niza.io/websocket-api-1.0/public-channels/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.
