Market API

Price Channel#

Retrieve the latest price data of a token. The fastest push frequency is 1 push per second. There will be no update if the event is not triggered.

Request URL

Please contact us dexapi@okx.com.

Request Parameters#

ParameterTypeRequiredDescription
opStringYesOperation, subscribe unsubscribe
argsArrayYesList of subscribed channels
channelStringYesChannel name,price
chainIndexStringYesUnique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex)
tokenContractAddressStringYesToken contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50)

Response Parameters#

ParameterTypeDescription
eventStringEvent, subscribe unsubscribe error
argObjectToken contract address
channelStringChannel name
chainIndexStringUnique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex)
tokenContractAddressStringToken contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50)
codeStringError code
msgStringError message

Push Data Parameters#

ParameterTypeDescription
argObjectSuccessfully subscribed channel
> channelStringChannel name
> chainIndexStringUnique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex)
> tokenContractAddressStringToken contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50)
dataArraySubscribed data
> timeStringTimestamp of the price, Unix timestamp format in milliseconds
> priceStringLatest token price

Request Example#

shell
{
  "op": "subscribe",
  "args": [
    {
      "channel": "price",
      "chainIndex": "1",
      "tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
    }
  ]
}

Response Example#

200

Successful response example

{
  "event": "subscribe",
  "arg": {
    "channel": "price",
    "chainIndex": "1"
    "tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
  },
  "connId": "a4d3ae55"
}

Failure response example

{
  "event": "error",
  "code": "60012",
  "msg": "Invalid request: {\"op\": \"subscribe\", \"argss\":[{ \"channel\" : \"price\", \"chainIndex\" : \"1\", \"tokenContractAddress\" : \"0x382bb369d343125bfb2117af9c149795c6c65c50\"}]}",
  "connId": "a4d3ae55"
}

Push data example

{
  "arg": {
    "channel": "price",
    "chainIndex": "1"
    "tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
  },
  "data": [
    {
    "time": "1716892020000",
    "price": "26.458143090226812",
    }
  ]
}