K线频道#
获取K线数据,推送频率最快是间隔1秒推送一次数据。
URL路径
请联系我们 dexapi@okx.com。
请求参数#
Parameter | Type | Required | Description |
---|---|---|---|
op | String | 是 | 操作,subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
channel | String | 是 | 频道名。 candle4H candle2H candle1H candle30m candle15m candle5m candle3m candle1m candle1s candle3M candle1M candle1W candle1D candle12H candle6H candle3Mutc candle1Mutc candle1Wutc candle1Dutc candle12Hutc candle6Hutc |
chainIndex | String | 是 | 链的唯一标识。 (如1代表Ethereum。更多可查看这里。) |
tokenContractAddress | String | 是 | 币种合约地址 |
响应参数#
Parameter | Type | Description |
---|---|---|
event | String | 事件, subscribe unsubscribe error |
arg | Object | 订阅的频道 |
channel | String | 频道名 |
chainIndex | String | 链的唯一标识。 |
tokenContractAddress | String | 币种合约地址 |
code | String | 错误码 |
msg | String | 错误消息 |
|connId | String | WebSocket连接ID |
推送数据参数#
Parameter | Type | Description |
---|---|---|
arg | Object | 订阅成功的频道 |
> channel | String | 频道名 |
> chainIndex | String | 链的唯一标识。 |
> tokenContractAddress | String | 币种合约地址 |
data | Array | 频道的数据 |
> ts | String | 开始时间,Unix时间戳的毫秒数格式,如 1597026383085 |
> o | String | 开盘价格 |
> h | String | 最高价格 |
> l | String | 最低价格 |
> c | String | 收盘价格 |
> vol | String | 交易量,以目标币种为单位 |
> volUsd | String | 交易量,以美元为单位 |
> confirm | String | K线状态。0 :K线未完结 1 :K线已完结 |
请求示例#
shell
{
"op": "subscribe",
"args": [
{
"channel": "candle1D",
"chainIndex": "1",
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
}
]
}
响应示例#
200
成功响应示例
{
"event": "subscribe",
"arg": {
"channel": "candle1D",
"chainIndex": "1"
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
},
"connId": "a4d3ae55"
}
失败响应示例
{
"event": "error",
"code": "60012",
"msg": "Invalid request: {\"op\": \"subscribe\", \"argss\":[{ \"channel\" : \"candle1D\", \"chainIndex\" : \"1\", \"tokenContractAddress\" : \"0x382bb369d343125bfb2117af9c149795c6c65c50\"}]}",
"connId": "a4d3ae55"
}
推送数据示例
{
"arg": {
"channel": "candle1D",
"chainIndex": "1"
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
},
"data": [
[
"1597026383085",
"8533.02",
"8553.74",
"8527.17",
"8548.26",
"529.5858061",
"226348.0482",
"0"
]
]
}