# 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"
    }
}
```
