K线频道#
获取K线数据,推送频率最快是间隔1秒推送一次数据。 
URL路径 
请联系我们 dexapi@okx.com。
请求参数#
| Parameter | Type | Required | Description | 
|---|---|---|---|
| op | String | 是 | 操作, subscribeunsubscribe | 
| args | Array | 是 | 请求订阅的频道列表 | 
| channel | String | 是 | 频道名。 dex-token-candle1sdex-token-candle1mdex-token-candle3mdex-token-candle5mdex-token-candle15mdex-token-candle30mdex-token-candle1Hdex-token-candle2Hdex-token-candle4Hdex-token-candle6Hdex-token-candle12Hdex-token-candle1Mdex-token-candle3Mdex-token-candle1Wdex-token-candle1Ddex-token-candle2Ddex-token-candle3Ddex-token-candle5Ddex-token-candle6Hutcdex-token-candle12Hutcdex-token-candle1Dutcdex-token-candle2Dutcdex-token-candle3Dutcdex-token-candle5Dutcdex-token-candle1Wutcdex-token-candle1Mutcdex-token-candle3Mutc | 
| chainIndex | String | 是 | 链的唯一标识。 (如1代表Ethereum。更多可查看这里。) | 
| tokenContractAddress | String | 是 | 币种合约地址,EVM 链请传全小写地址 | 
响应参数#
| Parameter | Type | Description | 
|---|---|---|
| event | String | 事件, subscribeunsubscribeerror | 
| 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": "dex-token-candle1s",
      "chainIndex": "1",
      "tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
    }
  ]
}
响应示例#
200
成功响应示例
{
  "event": "subscribe",
  "arg": {
    "channel": "dex-token-candle1s",
    "chainIndex": "1"
    "tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
  },
  "connId": "a4d3ae55"
}
失败响应示例
{
  "event": "error",
  "code": "60012",
  "msg": "Invalid request: {\"op\": \"subscribe\", \"argss\":[{ \"channel\" : \"dex-token-candle1s\", \"chainIndex\" : \"1\", \"tokenContractAddress\" : \"0x382bb369d343125bfb2117af9c149795c6c65c50\"}]}",
  "connId": "a4d3ae55"
}
推送数据示例
{
  "arg": {
    "channel": "dex-token-candle1s",
    "chainIndex": "1"
    "tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
  },
  "data": [
    [
      "1597026383085",
      "8533.02",
      "8553.74",
      "8527.17",
      "8548.26",
      "529.5858061",
      "226348.0482",
      "0"
    ]
  ]
}
