Candlesticks Channel#
Retrieve the candlesticks data of a token. The fastest push frequency is 1 push per second.
Request URL
Please contact us dexapi@okx.com.
Request Parameters#
Parameter | Type | Required | Description |
---|---|---|---|
op | String | Yes | Operation, subscribe unsubscribe |
args | Array | Yes | List of subscribed channels |
channel | String | Yes | Channel name. dex-token-candle1s dex-token-candle1m dex-token-candle3m dex-token-candle5m dex-token-candle15m dex-token-candle30m dex-token-candle1H dex-token-candle2H dex-token-candle4H dex-token-candle6H dex-token-candle12H dex-token-candle1M dex-token-candle3M dex-token-candle1W dex-token-candle1D dex-token-candle2D dex-token-candle3D dex-token-candle5D dex-token-candle6Hutc dex-token-candle12Hutc dex-token-candle1Dutc dex-token-candle2Dutc dex-token-candle3Dutc dex-token-candle5Dutc dex-token-candle1Wutc dex-token-candle1Mutc dex-token-candle3Mutc |
chainIndex | String | Yes | Unique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex) |
tokenContractAddress | String | Yes | Token contract address,for EVM please pass all-lowercase addresses (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50) |
Response Parameters#
Parameter | Type | Description |
---|---|---|
event | String | Event, subscribe unsubscribe error |
arg | Object | Token contract address |
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 |
Push Data Parameters#
Parameter | Type | Description |
---|---|---|
arg | Object | Successfully 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) |
data | Array | Subscribed data |
> ts | String | Opening time of the candlestick, Unix timestamp format in milliseconds, e.g. 1597026383085 |
> o | String | Open price |
> h | String | highest price |
> l | String | Lowest price |
> c | String | Close price |
> vol | String | Trading volume, with a unit of base currency |
> volUsd | String | Trading volume, with a unit of usd. |
> confirm | String | The state of candlesticks. 0 : represents that it is uncompleted 1 : represents that it is completed. |
Request Example#
shell
{
"op": "subscribe",
"args": [
{
"channel": "dex-token-candle1s",
"chainIndex": "1",
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
}
]
}
Response Example#
200
Successful response example
{
"event": "subscribe",
"arg": {
"channel": "dex-token-candle1s",
"chainIndex": "1"
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
},
"connId": "a4d3ae55"
}
Failure response example
{
"event": "error",
"code": "60012",
"msg": "Invalid request: {\"op\": \"subscribe\", \"argss\":[{ \"channel\" : \"dex-token-candle1s\", \"chainIndex\" : \"1\", \"tokenContractAddress\" : \"0x382bb369d343125bfb2117af9c149795c6c65c50\"}]}",
"connId": "a4d3ae55"
}
Push data example
{
"arg": {
"channel": "dex-token-candle1s",
"chainIndex": "1"
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
},
"data": [
[
"1597026383085",
"8533.02",
"8553.74",
"8527.17",
"8548.26",
"529.5858061",
"226348.0482",
"0"
]
]
}