Market API

Candlesticks Channel#

Retrieve the candlesticks data of a token. The fastest push frequency is 1 push per second.

Request URL

Please contact us dexapi@okx.com.

Request Parameters#

ParameterTypeRequiredDescription
opStringYesOperation, subscribe unsubscribe
argsArrayYesList of subscribed channels
channelStringYesChannel name. candle4H candle2H candle1H candle30m candle15m candle5m candle3m candle1m candle1s candle3M candle1M candle1W candle1D candle12H candle6H candle3Mutc candle1Mutc candle1Wutc candle1Dutc candle12Hutc candle6Hutc
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
> tsStringOpening time of the candlestick, Unix timestamp format in milliseconds, e.g. 1597026383085
> oStringOpen price
> hStringhighest price
> lStringLowest price
> cStringClose price
> volStringTrading volume, with a unit of base currency
> volUsdStringTrading volume, with a unit of usd.
> confirmStringThe state of candlesticks.
0: represents that it is uncompleted 1: represents that it is completed.

Request Example#

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

Response Example#

200

Successful response example

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

Failure response example

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

Push data example

{
  "arg": {
    "channel": "candle1D",
    "chainIndex": "1"
    "tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
  },
  "data": [
    [
      "1597026383085",
      "8533.02",
      "8553.74",
      "8527.17",
      "8548.26",
      "529.5858061",
      "226348.0482",
      "0"
    ]
  ]
}