# Perpetual Swap Websocket Market Data

# 1. Subscribe Market Depth Data

Subscribe to the push of a certain trading pair's market depth data; this topic sends the latest market depth as a snapshot. Snapshots are sent at a frequency of once every 1 second.

Subscription Type

The dataType is market.depth.$Symbol.$Step.$Level. E.g. market.depth.BTC-USDT.step0.level5

Subscription Parameters

Parameters Type Required Description
symbol String YES There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
step String YES Merged depth, step0,step1,step2,step3,step4,step5
level String YES Depth level, such as level5,level10,level20,level50,level100

"step" Merged Depth

Parameters Description
step0 Depth data will not be merged.
step1 Multiply the minimum precision of the price by 10 to merge the depth data
step2 Multiply the minimum precision of the price by 100 to merge the depth data
step3 Multiply the minimum precision of the price by 1,000 to merge the depth data
step4 Multiply the minimum precision of the price by 10,000 to merge the depth data
step5 Multiply the minimum precision of the price by 100,000 to merge the depth data

"level" Depth Level

Parameters Description
level5 level 5
level10 level 10
level20 level 20
level50 level 50
level100 level 100

Push Data

Return Parameters Description
code With regards to error messages, 0 means normal, and 1 means error
dataType The type of subscribed data, such as market.depth.BTC-USDT.step0.level5
data Push Data
asks Sell side depth
bids Buy side depth
p price
v volume
    # Response
    {
        "code": 0,
        "dataType": "market.depth.BTC-USDT.step0.level5",
        "data": {
            "asks": [{
                    "p": 5319.94,
                    "v": 0.05483456
                },{
                    "p": 5320.19,
                    "v": 1.05734545
                },{
                    "p": 5320.39,
                    "v": 1.16307999
                },{
                    "p": 5319.94,
                    "v": 0.05483456
                },{
                    "p": 5320.19,
                    "v": 1.05734545
                },{
                    "p": 5320.39,
                    "v": 1.16307999
                },
            ],
            "bids": [{
                    "p": 5319.94,
                    "v": 0.05483456
                },{
                    "p": 5320.19,
                    "v": 1.05734545
                },{
                    "p": 5320.39,
                    "v": 1.16307999
                },{
                    "p": 5319.94,
                    "v": 0.05483456
                },{
                    "p": 5320.19,
                    "v": 1.05734545
                },{
                    "p": 5320.39,
                    "v": 1.16307999
                },
            ],
        }
    }

# 2. Subscribe the Latest Trade Detail

Subscribe to the trade detail data of a trading pair

Subscription Type

The dataType is market.trade.detail.$Symbol.
E.g. market.trade.detail.BTC-USDT

Subscription Parameters

Parameters Type Required Field description Description
symbol String YES Trading pair symbol There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT

Push Data

Return Parameters Description
code With regards to error messages, 0 means normal, and 1 means error
dataType The type of data subscribed, such as market.tradeDetail.BTC-USDT
data Push Data
trades Deal by deal
time Closing Time
makerSide Direction ( Bid / Ask)
price Closing Price
volume Filled Amount
 # Response
 {
     "code": 0,
     "dataType": "market.tradeDetail.BTC-USDT",
     "data": {
         "trades": [
             {
                 "time": "2018-04-25T15:00:51.999Z",
                 "makerSide": "Bid",
                 "price": 0.279563,
                 "volume": 100,
             },
             {
                 "time": "2018-04-25T15:00:51.000Z",
                 "makerSide": "Ask",
                 "price": 0.279563,
                 "volume": 300,
             }
         ]
     }
 }

# 3. Subscribe K-Line Data

Subscribe to market k-line data of one trading pair

Subscription Type

The dataType is market.kline.$Symbol.$KlineType.
E.g. market.kline.BTC-USDT.1min

Subscription Parameters

Parameters Type Required Field Description Description
symbol String YES Trading pair symbol There must be a hyphen/ "-" in the trading pair symbol. eg: BTC-USDT
klineType String YES K-Line Type The type of K-Line ( minutes, hours, weeks etc.)

Remarks

klineType Field Description
1min 1 min Kline
3min 3 min Kline
5min 5 min Kline
15min 15 min Kline
30min 30 min Kline
1hour 1-hour Kline
2hour 2-hour Kline
4hour 4-hour Kline
6hour 6-hour Kline
12hour 12-hour Kline
1day 1-Day Kline
1week 1-Week Kline
1month 1-Month Kline

Push Data

Return Parameters Field Description
code With regards to error messages, 0 means normal, and 1 means error
data Push Data
dataType Data Type
klineInfosVo Kline Data
close Closing Price
high High
low Low
open Opening Price
statDate Kline Date
time The timestamp of K-Line,Unit: ms
volume Volume
 # Response
 {
     "code": 0,
     "data": {
         "klineInfosVo": [
             {
                 "close": 54564.31,
                 "high": 54711.73,
                 "low": 54418.27,
                 "open": 54577.41,
                 "statDate": "2021-04-29T11:00:00.000+0800",
                 "time": 1619665200000,
                 "volume": 1607.0727000000002
             }
         ]
     },
     "dataType": "market.kline.BTC-USDT.30min"
 }

Remarks

For more about return error codes, please see the error code description on the homepage.

Last Updated: 11/3/2022, 2:59:23 PM