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. dex-token-candle1s dex-token-candle1m dex-token-candle3m dex-token-candle5m dex-token-candle15m dex-token-candle30m dex-token-candle1H dex-token-candle2H dex-token-candle4H dex-token-candle6H dex-token-candle12H dex-token-candle1M dex-token-candle3M dex-token-candle1W dex-token-candle1D dex-token-candle2D dex-token-candle3D dex-token-candle5D dex-token-candle6Hutc dex-token-candle12Hutc dex-token-candle1Dutc dex-token-candle2Dutc dex-token-candle3Dutc dex-token-candle5Dutc dex-token-candle1Wutc dex-token-candle1Mutc dex-token-candle3Mutc
chainIndexStringYesUnique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex)
tokenContractAddressStringYesToken contract address,for EVM please pass all-lowercase addresses (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": "dex-token-candle1s",
      "chainIndex": "1",
      "tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
    }
  ]
}

Response Example#

200

Successful response example

{
  "event": "subscribe",
  "arg": {
    "channel": "dex-token-candle1s",
    "chainIndex": "1"
    "tokenContractAddress":"0x382bb369d343125bfb2117af9c149795c6c65c50"
  },
  "connId": "a4d3ae55"
}

Failure response example

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

Push data example

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