价格频道#
获取代币最新价格,推送频率最快是间隔1秒推送一次数据。价格不更新不推送。
URL路径
请联系我们 dexapi@okx.com。
请求参数#
Parameter | Type | Required | Description |
---|---|---|---|
op | String | 是 | 操作, subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
channel | String | 是 | 频道名,price |
chainIndex | String | 是 | 链的唯一标识。 (如1代表Ethereum。更多可查看这里。) |
tokenContractAddress | String | 是 | 币种合约地址 |
响应参数#
Parameter | Type | Description |
---|---|---|
event | String | 事件, subscribe unsubscribe error |
arg | Object | 订阅的频道 |
channel | String | 频道名 |
chainIndex | String | 链的唯一标识。 (如1代表Ethereum。更多可查看这里。) |
tokenContractAddress | String | 币种合约地址 |
code | String | 错误码 |
msg | String | 错误消息 |
connId | String | WebSocket连接ID |
推送数据参数#
Parameter | Type | Description |
---|---|---|
arg | Object | 订阅成功的频道 |
> channel | String | 频道名 |
> chainIndex | String | 链的唯一标识。 |
> tokenContractAddress | String | 币种合约地址 |
data | Array | 频道的数据 |
> time | String | 价格的时间,Unix 时间戳格式,用毫秒表示 |
> price | String | 最新代币价格 |
请求示例#
shell
{
"op": "subscribe",
"args": [
{
"channel": "price",
"chainIndex": "1",
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
}
]
}
响应示例#
200
成功响应示例
{
"event": "subscribe",
"arg": {
"channel": "price",
"chainIndex": "1"
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
},
"connId": "a4d3ae55"
}
失败响应示例
{
"event": "error",
"code": "60012",
"msg": "Invalid request: {\"op\": \"subscribe\", \"argss\":[{ \"channel\" : \"price\", \"chainIndex\" : \"1\", \"tokenContractAddress\" : \"0x382bb369d343125bfb2117af9c149795c6c65c50\"}]}",
"connId": "a4d3ae55"
}
推送数据示例
{
"arg": {
"channel": "price",
"chainIndex": "1"
"tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
},
"data": [
{
"time": "1716892020000",
"price": "26.458143090226812",
}
]
}