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

# Recent Trades

The trade channel generates a trade event when orders are matched in the book. Multiple trades may be batched in a single message but that does not mean that these trades resulted from a single taker order.

{% 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("trade.{pair}");
```

### Subscribe Request Payload

```javascript
{
   "event": "pusher:subscribe",
   "data": {
       "channel": "trade.{pair}"
   }
}
```

### Examples

<details>

<summary>Pusher</summary>

```javascript
var channel = pusher.subscribe("trade.NIZAUSDT");
```

</details>

<details>

<summary>WebSocket API in Javascript</summary>

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

</details>

### Payload

| Name           | Type    | Description                                                          |
| -------------- | ------- | -------------------------------------------------------------------- |
| channel        | string  | The name of the channel                                              |
| type           | string  | Type of event notification                                           |
| data           | array   | The payload of trade data                                            |
| data.ord\_type | string  | Possible values: \[limit, market] The order type of the taker order. |
| data.price     | decimal | Average price of the trade.                                          |
| data.qty       | decimal | Size of the trade.                                                   |
| data.side      | string  | The side of the taker order.                                         |
| data.symbol    | string  | Example: "NIZA/USD" The symbol of the currency pair.                 |
| data.timestamp | string  | Format: RFC3339. The book order update timestamp.                    |
| data.trade\_id | integer | Trade identifier is a sequence number, unique per book               |

### Example of the Payload

```json
{
   "channel": "trade",
   "type": "update",
   "data": [
       {
           "ord_type": "limit",
           "price": "100.00000000",
           "qty": "100.00000000",
           "side": "sell",
           "symbol": "NIZA\/USDT",
           "timestamp": "2024-09-18 23:31:27.572200",
           "trade_id": 78236
       }
   ]
}
```
