Subscribe#
WebSocket channels are all private channels.
Private channels -- including price channel, candlesticks channel, and trades channel, etc-- require logging in.
Users can choose to subscribe to one or more channels, and the total length of multiple channels cannot exceed 64 KB.
Below is an example of subscription parameters. The requirement of subscription parameters for each channel is different.
For details, please refer to the specification of each channel.
Request Parameters#
Parameter | Type | Required | Description |
---|---|---|---|
op | String | Yes | Operation, subscribe |
args | Array | Yes | List of subscribed channels |
> channel | String | Yes | Channel name |
> chainIndex | String | Yes | Unique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex) |
> timestamp | String | Yes | Unix Epoch time, the unit is seconds |
> tokenContractAddress | String | Yes | Token contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50) |
Response Parameters#
Parameter | Type | Description |
---|---|---|
event | String | Operation.subscribe or error |
arg | String | Subscribed channel |
> channel | String | Channel name |
> chainIndex | String | Unique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex) |
> tokenContractAddress | String | Token contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50) |
code | String | Error code |
msg | String | Error message |
connId | String | WebSocket connection ID |
Request format description
{"op": "subscribe","args": ["SubscriptionTopic"]}
Request Example#
shell
{
"op": "subscribe",
"args": [{
"channel": "price",
"chainIndex": "1",
"tokenContractAddress": "0x382bb369d343125bfb2117af9c149795c6c65c50"
}]
}
Response Example#
200
{
"event": "subscribe",
"arg": {
"channel": "price",
"chainIndex": "1"
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
},
"connId": "accb8e21"
}