Subscribing will allow you to receive updates on any changes to a topic. To subscribe and receive this information, you must send a sub message. The proper formatting to use when sending a sub message is as follows:
//request
{
"sub": "topic to sub",
"id": "id generate by client"
}
For example,
//request
{
"sub": "market.btcusdt.kline.1min",
"id": "id1"
}
The above subscription request is expected to solicit the following response from the server:
//response
{
"id": "id1",
"status": "ok",
"subbed": "market.btcusdt.kline.1min",
"ts": 1489474081631
}
An example of an update via the subscription system is as follows:
//example
{
"ch": "market.btcusdt.kline.1min",
"ts": 1489474082831,
"tick": {
"id": 1489464480,
"amount": 0.0,
"count": 0,
"open": 7962.62,
"close": 7962.62,
"low": 7962.62,
"high": 7962.62,
"vol": 0.0
}
}
If an incorrect sub message is sent, the subscription attempt will fail and the server will respond with an error message.
For example, a sub message with an invalid symbol would solicit the following response from the server:
//response
{
"id": "id2",
"status": "error",
"err-code": "bad-request",
"err-msg": "invalid topic market.invalidsymbol.kline.1min",
"ts": 1494301904959
}