# Subscribe Incremental Market Depth Data

#### market.$contract\_code.depth.size\_${size}.high\_freq&#x20;

Signature verification: No

Interface permission: Read

Rate Limit: For public interface to get market data such as Get Kline data, Get Market Data Overview, Get Contract Information,Get market in-depth data, Get premium index Kline, Get real-time forecast capital rate kline, Get basis data, Get the last Trade of a Contract and so on： For websocket: The rate limit for “req” request is 50 times at once. No limit for “sub” request as the data will be pushed by sever voluntarily.

Interface description: The interface supports cross margin mode and isolated margin mode. The request parameter "contract\_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.

### Subscription Address

| Environment                         | Address                         |
| ----------------------------------- | ------------------------------- |
| Online                              | wss\://api.sunx.io/ws/v1/market |
| Online (preferred by aws customers) | wss\://api.sunx.io/ws/v1/market |

### Subscription Parameter

| Parameter      | Data Type | Required | Description                    | Value Range | Default Value                                                                                             |
| -------------- | --------- | -------- | ------------------------------ | ----------- | --------------------------------------------------------------------------------------------------------- |
| contract\_code | string    | true     | contract code or contract type |             | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
| size           | string    | true     | Depth size                     |             | 30: stands for 30 unmerged data. 150:stands for 150 unmerged data.                                        |

### Data Update

| Parameter | Data Type | Required | Description                                                                     | Value Range |
| --------- | --------- | -------- | ------------------------------------------------------------------------------- | ----------- |
| ts        | string    | true     | Timestamp of Respond Generation, Unit: Millisecond                              |             |
| ch        | long      | true     | Data channel, Format：market.$contract\_code.depth.size\_${size}.high\_freq      |             |
| \<tick>   |           | false    |                                                                                 |             |
| mrid      | long      | true     | Order ID                                                                        |             |
| id        | long      | true     | tick ID，system timestamp.seconds                                                |             |
| asks      | object    | true     | Sell,\[price(Ask price), vol(Ask orders (cont.) )], price in ascending sequence |             |
| bids      | object    | true     | Buy,\[price(Bid price), vol(Bid orders(Cont.))], Price in descending sequence   |             |
| ts        | long      | true     | Timepoint for system detecting orderbook, unit: millisecond                     |             |
| version   | long      | true     | version ID,auto increment ID.                                                   |             |
| event     | string    | true     | event type: update or snapshot                                                  |             |
| ch        | string    | true     | Data channel, Format： market.$contract\_code.depth.size\_${size}.high\_freq     |             |
| \</tick>  |           | false    |                                                                                 |             |

Notes: \
when data\_type is incremental,snapshot data wil be pushed for the first time. When re-connection occurs, snapshort data will be pushed for the first time.\
version: auto increment in single websocket connection. version may be different among several websocket subscription connections.\
orderbook will be pushed if orderbook is updated whenever incremental or snapshot.\
orderbook event will be checked every 30ms. If there is no orderbook event, you will not receive any orderbook data.\
you HAVE TO maintain local orderbook data,such as updating your local orderbook bids and asks data.

### Subscription Example

```
{
  "sub": "market.BTC-USDT.depth.size_20.high_freq",
  "data_type": "incremental",
  "id": "id generated by client"
}
```

### Example of a Successful Subscription

```
{
  "status": "ok",
  "subbed": "market.BTC-USDT.depth.size_20.high_freq",
  "data_type": "incremental",
  "id": "id generated by client",
  "ts": 1489474081631
}
```

### Example of a Data Update

```
{
  "ch": "market.BTC-USDT.depth.size_20.high_freq",
  "tick": {
    "asks": [
      [
        13081.9,
        206
      ],
      [
        13099.7,
        371
      ]
    ],
    "bids": [
      [
        13071.9,
        38
      ],
      [
        13060,
        400
      ]
    ],
    "ch": "market.BTC-USDT.depth.size_20.high_freq",
    "event": "snapshot",
    "id": 131597620,
    "mrid": 131597620,
    "ts": 1603707712356,
    "version": 1512467
  },
  "ts": 1603707712357
}
```

### Example of a Subscription Cancellation

```
{
  "unsub": "market.BTC-USDT.depth.size_20.high_freq",
  "data_type": "incremental",
  "id": "id generated by client"
}
```
