Market Data
Subscription Examples
Sample Requests and Stream
Request → Receipt Confirmation → Stream (continuous feed)
Candlesticks
Continuous feed of candlestick data with default/provided depth.
Valid channels are: candles_minute_1
, candles_minute_5
, candles_minute_10
, candles_minute_15
, candles_minute_30
, candles_hour_1
, candles_hour_2
, candles_hour_4
, candles_hour_6
, candles_hour_12
, candles_day_1
, candles_day_3
, candles_week_1
and candles_month_1
Stream Response Field | Data Type | Description |
---|---|---|
symbol | String | symbol name |
amount | String | quote units traded over the interval |
high | String | highest price over the interval |
quantity | String | base units traded over the interval |
tradeCount | Integer | count of trades |
low | String | lowest price over the interval |
closeTime | Long | close time of interval |
startTime | Long | start time of interval |
close | String | price at the end time |
open | String | price at the start time |
ts | Long | time the record was pushed |
Example:
# --> Request
{
"event": "subscribe",
"channel": ["candles_minute_1"],
"symbols": ["btc_usdt"]
}
# <-- Receipt Confirmation
{
"channel": "candles_minute_1",
"event": "subscribe",
"symbols": ["BTC_USDT"]
}
# <-- Stream
{
"channel": "candles_minute_1",
"data": [{
"symbol": "BTC_USDT",
"amount": "0",
"high": "9999.07",
"quantity": "0",
"tradeCount": 0,
"low": "9999.07",
"closeTime": 1648057199999,
"startTime": 1648057140000,
"close": "9999.07",
"open": "9999.07",
"ts": 1648057141081
}
}]
}
Trades
Continuous feed of recent trades with default/provided depth.
Stream Response Field | Data Type | Description |
---|---|---|
symbol | String | symbol name |
amount | String | quote units traded |
takerSide | String | trade side (buy, sell) |
quantity | String | base units traded |
createTime | Long | time the trade was created |
price | String | trade price |
id | Long | trade id |
ts | Long | time the record was pushed |
Example:
# --> Request
{
"event": "subscribe",
"channel": ["trades"],
"symbols": ["BTC_USDT"]
}
# <-- Receipt Confirmation
{
"channel": "trades",
"event": "subscribe",
"symbols": ["BTC_USDT"]
}
# <-- Stream
{
"channel": "trades",
"data": [{
"symbol": "BTC_USDT",
"amount": "70",
"takerSide": "buy",
"quantity": "4",
"createTime": 1648059516810,
"price": "104",
"id": 1648059516810,
"ts": 1648059516832
}]
}
Ticker
Continuous feed (updated every second) of current day ticker data
Stream Response Field | Data Type | Description |
---|---|---|
symbol | String | symbol name |
dailyChange | String | daily change in decimal |
high | String | highest price over the last 24h |
amount | String | quote units traded over the last 24h |
quantity | String | base units traded over the last 24h |
tradeCount | Integer | count of trades |
low | String | lowest price over the last 24h |
closeTime | Long | close time for the 24h interval |
startTime | Long | start time for the 24h interval |
close | String | price at the end time |
open | String | price at the start time |
ts | Long | time the record was pushed |
markPrice | String | mark price at the end time |
Example:
# --> Request
{
"event": "subscribe",
"channel": ["ticker"],
"symbols": ["ETH_USDT"]
}
# <-- Receipt Confirmation
{
"channel": "ticker",
"event": "subscribe",
"symbols": ["ETH_USDT"]
}
# <-- Stream
{
"channel": "ticker",
"data": [{
"symbol": "ETH_USDT",
"dailyChange": "0.9428",
"high": "507",
"amount": "20",
"quantity": "3",
"tradeCount": 11,
"low": "16",
"closeTime": 1634062351868,
"startTime": 1633996800000,
"close": "204",
"open": "105",
"ts": 1648052794867,
"markPrice": "205",
}]
}
Ticker (All Symbols)
# --> Request
{
"event": "subscribe",
"channel": ["ticker"],
"symbols": ["all"]
}
# <-- Receipt Confirmation
{
"channel": "ticker",
"event": "subscribe",
"symbols": ["all"]
}
# <-- Stream
{
"channel": "ticker",
"data": [{
"symbol": "BTC_USDT",
"dailyChange": "-0.7409",
"high": "38596.3",
"amount": "26843.353145272",
"quantity": "101.00438344",
"tradeCount": 13,
"low": "0.8654",
"closeTime": 1648054681007,
"startTime": 1647968280000,
"close": "9999.07",
"open": "38596.3"
"ts": 1648054693082,
"markPrice": "38234.43"
}]
}
# <-- Stream (continued)
{
"channel": "ticker",
"data": [{
"symbol": "ETH_USDT",
"dailyChange": "0.9428",
"high": "507",
"amount": "20",
"quantity": "3",
"tradeCount": 11,
"low": "16",
"closeTime": 1634062351868,
"startTime": 1633996800000,
"close": "204",
"open": "105",
"ts": "1648052794867",
"markPrice": "205"
}]
}
Book
Continuous feed of order book data containing asks and bids with default/provided depth. Default depth is 5. Valid depths are 5, 10, or 20, which can be specified using depth field as shown in the example. Order book is updated every 100ms.
Stream Response Field | Data Type | Description |
---|---|---|
symbol | String | symbol name |
createTime | Long | time the record was created |
asks | List<String> | sell orders, in ascending order of price |
bids | List<String> | buy orders, in descending order of price |
id | Long | id of the record (SeqId) |
ts | Long | send timestamp |
Example:
# --> Request
{
"event": "subscribe",
"channel": ["book"],
"symbols": ["BTC_USDT"]
}
# --> Request With Depth Parameter
{
"event": "subscribe",
"channel": ["book"],
"symbols": ["BTC_USDT"],
"depth": 10
}
# <-- Receipt Confirmation
{
"channel": "book",
"event": "subscribe",
"symbols": ["BTC_USDT"]
}
# <-- Stream
{
"channel": "book",
"data": [{
"symbol": "BTC_USDT",
"createTime": 1648052239156,
"asks": [],
"bids": [
["40001.5", "2.87"],
["39999.4", "1"]
],
"id": 123456,
"ts": 1648052239192
},
…
{
"symbol": "BTC_USDT",
"createTime": 1648052239156,
"asks": [],
"bids": [
["40001", "2.87"],
["39999", "1"]
],
"id": 345678,
"ts": 1648052239192
}]
}
…
Book Level 2
Receive a snapshot of the full 20 level order book. Then, continuously in realtime receive an updated order book when the first 20 levels change.
To maintain a copy of the order book locally:
- Send a book_lv2 subscription message.
- Receive a snapshot message from the server.
- Use an appropriate data structure to store the received book.
- Receive an incremental order book message (
update
) from the server and make changes depending on[price, quantity]
pair data:- When quantity is positive, update the corresponding price of your order book with this quantity.
- When quantity is 0, delete this price from your order book.
- Receive an order book message (
snapshot
) from the server, reset your order book data structure to match this new order book.
Note: If id
of the last message does not match lastId
of the current message then the client has lost connection with the server and must re-subscribe to the channel.
Stream Response Field | Data Type | Description |
---|---|---|
symbol | String | symbol name |
asks | List<String> | sell orders, in ascending order of price |
bids | List<String> | buy orders, in descending order of price |
createTime | Long | time the record was created |
lastId | Long | the id of the previous message |
id | Long | id of the record (SeqId) |
ts | Long | send timestamp |
Example:
# --> Request
{
"event": "subscribe",
"channel": ["book_lv2"],
"symbols": ["btc_usdt"]
}
# <-- Receipt confirmation
{
"channel": "book_lv2",
"event": "subscribe",
"symbols": ["BTC_USDT"]
}
# <-- Stream (snapshot)
{
"channel": "book_lv2",
"action": "snapshot",
"data": [{
"symbol": "BTC_USDT",
"asks": [
["6.16", "0.6"],
["6.17", "1"],
["6.18", "1"],
...
],
"bids": [
["5.65", "0.02"],
["5.61", "1.68"],
["5.6", "25.38"],
...
],
"createTime": 1653029116343,
"lastId": 10409,
"id": 10410,
"ts": 1652774727337
}]
}
# <-- Stream (update)
{
"channel": "book_lv2",
"action": "update",
"data": [{
"symbol": "BTC_USDT",
"asks": [
["6.35", "3"]
],
"bids": [
["5.65", "0.02"]
],
"createTime": 1653029116345,
"lastId": 10410,
"id": 10421,
"ts": 1653029116529
}]
}