获取历史 K 线#
获取历史 K线数据。
请求地址#
GET https://web3.okx.com/api/v5/dex/market/historical-candles
请求参数#
Parameter | Type | Required | Description |
---|---|---|---|
chainIndex | String | 是 | 链的唯一标识。 (如 1 代表 Ethereum。更多可查看这里)。 |
tokenContractAddress | String | 是 | 币种合约地址 (如:0x382bb369d343125bfb2117af9c149795c6c65c50) |
bar | String | 否 | 时间粒度,默认值1m 。如 [1s/1m/3m/5m/15m/30m/1H/2H/4H] 香港时间开盘价k线:[6H/12H/1D/1W/1M/3M] UTC时间开盘价k线:[/6Hutc/12Hutc/1Dutc/1Wutc/1Mutc/3Mutc] |
after | String | 否 | 请求此时间戳之前(更旧的数据)的分页内容,传的值为对应接口的ts |
before | String | 否 | 请求此时间戳之后(更新的数据)的分页内容,传的值为对应接口的ts, 单独使用时,会返回最新的数据。 |
limit | String | 否 | 分页返回的结果集数量,最大为299,不填默认返回100条 |
响应参数#
Parameter | Type | Description |
---|---|---|
ts | String | 开始时间,Unix时间戳的毫秒数格式,如 1597026383085 |
o | String | 开盘价格 |
h | String | 最高价格 |
l | String | 最低价格 |
c | String | 收盘价格 |
vol | String | 交易量,以目标币种为单位 |
volUsd | String | 交易量,以美元为单位 |
confirm | String | K线状态 0 :K线未完结 1 :K线已完结 |
解释
返回值数组顺序分别为是:[ts,o,h,l,c,vol,volUsd,confirm] 取前一根K线的收盘价作为后一根K线的开盘价
请求示例#
shell
curl --location --request GET 'https://web3.okx.com/api/v5/dex/market/historical-candles?chainIndex=66&tokenContractAddress=0x382bb369d343125bfb2117af9c149795c6c65c50' \
--header 'OK-ACCESS-PROJECT: 86af********d1bc' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z'
响应示例#
200
{
"code":"0",
"data":[
[
"1597026383085",
"3.721",
"3.743",
"3.677",
"3.708",
"22698348.04828491",
"226348.0482",
"0"
],
[
"1597026383085",
"3.731",
"3.799",
"3.494",
"3.72",
"67632347.24399722",
"6767.2439",
"1"
]
],
"msg":""
}