获取历史综合币价#
查询某个代币的历史综合价格。
请求路径#
GET https://web3.okx.com/api/v5/dex/index/historical-price
请求参数#
Parameter | Type | Required | Description |
---|---|---|---|
chainIndex | String | 是 | 链唯一标识。(如1 代表Ethereum。更多可查看这里。) |
tokenAddress | String | 否 | 代币地址。1 :传""代表查询对应链的主链币。2 :传具体的代币合约地址,代表查询对应的代币。 |
limit | String | 否 | 每次查询多少条,默认值为 50,最大 200。 |
cursor | String | 否 | 游标位置,默认为第一个。 |
begin | String | 否 | 开始时间,查询晚于该时间的历史币价。Unix时间戳,用毫秒表示。 |
end | String | 否 | 结束时间,查询早于该时间的历史币价。若 begin 和 end 都不传,查询当前时间以前的历史币价。Unix 时间戳,用毫秒表示。 |
period | String | 否 | 时间间隔单位: 1m : 1分钟 5m : 5分钟 30m : 30分钟 1h : 1小时 1d : 1天(默认)。 |
响应参数#
Parameter | Type | Description |
---|---|---|
prices | Array | 历史价格的列表 |
>time | String | 分钟时间戳(整分钟) |
>price | String | 币种价格,单位为美元,18 位精度 |
cursor | String | 游标位置 |
请求示例#
shell
curl --location --request GET 'https://web3.okx.com/api/v5/dex/index/historical-price?chainIndex=1&limit=5&begin=1700040600000&period=5m' \
--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",
"msg": "success",
"data": [
{
"cursor":"31",
"prices":[
{
"time": "1700040600000",
"price": "1994.430000000000000000"
},
{
"time": "1700040300000",
"price": "1994.190000000000000000"
},
{
"time": "1700040000000",
"price": "1992.090000000000000000"
},
{
"time": "1700039700000",
"price": "1992.190000000000000000"
},
{
"time": "1700039400000",
"price": "1990.190000000000000000"
}
]
}
]
}