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. candle4H candle2H candle1H candle30m candle15m candle5m candle3m candle1m candle1s candle3M candle1M candle1W candle1D candle12H candle6H candle3Mutc candle1Mutc candle1Wutc candle1Dutc candle12Hutc candle6Hutc |
chainIndex | String | Yes | Unique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex) |
tokenContractAddress | String | Yes | Token contract address (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": "candle1D",
"chainIndex": "1",
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
}
]
}
Response Example#
200
Successful response example
{
"event": "subscribe",
"arg": {
"channel": "candle1D",
"chainIndex": "1"
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
},
"connId": "a4d3ae55"
}
Failure response example
{
"event": "error",
"code": "60012",
"msg": "Invalid request: {\"op\": \"subscribe\", \"argss\":[{ \"channel\" : \"candle1D\", \"chainIndex\" : \"1\", \"tokenContractAddress\" : \"0x382bb369d343125bfb2117af9c149795c6c65c50\"}]}",
"connId": "a4d3ae55"
}
Push data example
{
"arg": {
"channel": "candle1D",
"chainIndex": "1"
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
},
"data": [
[
"1597026383085",
"8533.02",
"8553.74",
"8527.17",
"8548.26",
"529.5858061",
"226348.0482",
"0"
]
]
}