Market API

Subscribe#

Users can choose to subscribe to one or more channels, with the total length of all channels not exceeding 64 KB.
Price channels and trading channels require authentication before subscription.
K-line (candlestick) channels do not require authentication.

Below is an example of request parameters. Each channel has different parameter requirements, so please subscribe according to the specific requirements 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,for EVM please pass all-lowercase addresses (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"
}