Market API

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#

ParameterTypeRequiredDescription
opStringYesOperation, subscribe
argsArrayYesList of subscribed channels
> channelStringYesChannel name
> chainIndexStringYesUnique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex)
> timestampStringYesUnix Epoch time, the unit is seconds
> tokenContractAddressStringYesToken contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50)

Response Parameters#

ParameterTypeDescription
eventStringOperation.subscribe or error
argStringSubscribed channel
> channelStringChannel name
> chainIndexStringUnique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex)
> tokenContractAddressStringToken contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50)
codeStringError code
msgStringError message
connIdStringWebSocket 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"
}