> For the complete documentation index, see [llms.txt](https://docs.zkex.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zkex.com/zkex2.0-market-maker-apis/websocket-data-push.md).

# Websocket Data Push

## Overview

***

### Snapshot data

* Subscribe channel : `level2`
* Push only once, when the `level2` channel is established

***

### Data changes

* Subscribe channel : `level2`

```
  {
   "type": "l2update",
   "productId": "UNI-USDC",
   "time": 1686645711,
   "changes": [
     [
       "sell",
       "90000000000000000000",  // price
       "100000000000"     // amount
     ]
   ]
  }
```

***

### K-line data

* Subscribe channel: `candles_1m`,`candles_3m`,`candles_5m`....
* Maximum 1 push within 1s

```
{
 "type": "candles_1m",
 "productId": "UNI-USDC",
 "time": 1653273480,
 "open":  "1100000000000000000",          
 "close":  "1100000000000000000",          
 "low":  "1100000000000000000",            
 "high": "1100000000000000000",           
 "volume": "10000000000000000000"          
}
```

***

### Ticker info

* Subscribe channel: `match`
* Maximum 1 push within 3s

```
{
 "type": "ticker",
 "tradeSeq": 20,
 "sequence": 85,
 "time": 1650958799,
 "productId": "UNI-USDC",
 "price": "90000000000",      
 "side": "sell",       
 "lastSize": "10000000",
 "bestBid": "",
 "bestAsk": "",
 "volume24h": "110000000000000000", 
 "volume30d": "310000000000000000", 
 "low24h": "1000000000000000",     
 "high24h": "1000000000000000",    
 "open24h": "1000000000000000",
 "close24h": "1000000000000000"    
}
```

***

### Matching info

* Subscribe channel: `match`
* Since the settlement of ZKEX is in Layer 2, `match` only means that the matching is successful, not that the transaction is successful

```
{
 "type": "match",
 "tradeSeq": 20,
 "sequence": 100,
 "time": 1650958799,
 "productId": "UNI-USDC",
 "price": "900000000000",
 "size": "1000000000",
 "makerOrderId": "1666371045063401472",     # maker's order id
 "takerOrderId": "1666371045063401471",     # taker's order id
 "side": "sell"
}
```

***

### Trading info

* Subscribe channel: `trade`
* After the `match` channel is pushed, if layer2 is actually done, the `trade` channel will be pushed.

```
{
 "type": "trade",
 "tradeSeq": 20,
 "time": 1650958799,
 "productId": "UNI-USDC",
 "price": "900000000000",
 "size": "1000000000",
 "makerOrderId": "1666371045063401472",     # maker's order id
 "takerOrderId": "1666371045063401471",     # taker's order id
 "side": "sell",
 "status": 2,
 "failReason": ""
}
```

***

### Order change infomation of a trading pair

* Subscribe channel: `order`

```
{
 "userId": 1,
 "clientOid": "1234",
 "type": "order",
 "sequence": 0,
 "id": "50",
 "price": "1000000000",
 "size": "1000000000000",
 "funds": "0",
 "productId": "UNI-USDC",
 "side": "sell",
 "orderType": "limit", 
 "createdAt": 1650958799,
 "fillFees": "0",         # fee (calculated in quote tokens)
 "filledSize": "0",       # number of successfully matched (calculated in base tokens)
 "executedValue": "0",     # value of successfully matched (calculated in quote tokens)
 "status": "new",      # order status:   `new`, `open`, `filled`, `cancelled`, `cancelling`, `partial`
 "settled": false,     # whether the matching was successful
 "timeInForce": "GTC"     
}
```

***

### The asset change information of an account

* Subscribe channel: `funds`

```
{
 "type": "funds",
 "sequence": 0,
 "userId": "1",
 "currencyCode": "UNI",
 "available": "820900000000000000", 
 "hold": "11741000000000000000"  
}
```


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.zkex.com/zkex2.0-market-maker-apis/websocket-data-push.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
