Market API

Get Candlesticks#

Retrieve the candlestick charts. This endpoint can retrieve the latest 1,440 data entries. Charts are returned in groups based on the requested bar.

Request URL#

GET https://web3.okx.com/api/v5/dex/market/candles

Request Parameters#

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier for the chain.
e.g., 1: Ethereum.
See more here.
tokenContractAddressStringYesToken contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50)
afterStringNoPagination of data to return records earlier than the requested ts.
beforeStringNoPagination of data to return records newer than the requested ts. The latest data will be returned when using before individually
barStringNoBar size, the default is 1m
e.g. [1s/1m/3m/5m/15m/30m/1H/2H/4H]
Hong Kong time opening price k-line:[6H/12H/1D/1W/1M/3M]
UTC time opening price k-line:[/6Hutc/12Hutc/1Dutc/1Wutc/1Mutc/3Mutc]
limitStringNoNumber of results per request. The maximum is 299. The default is 100.

Response Parameters#

ParameterTypeDescription
tsStringOpening time of the candlestick, Unix timestamp format in milliseconds, e.g. 1597026383085
oStringOpen price
hStringOpen price
lStringLowest price
cStringClose price
volStringTrading volume, with a unit of base currency.
volUsdStringTrading volume, with a unit of usd.
confirmString"The state of candlesticks. 0 represents that it is uncompleted, 1 represents that it is completed."
Explanation

The first candlestick data may be incomplete, and should not be polled repeatedly. The data returned will be arranged in an array like this: [ts,o,h,l,c,vol,volUsd,confirm]. Use the closing price of the last candle as the opening price of the following candle.

Request Example#

shell
curl --location --request GET 'https://web3.okx.com/api/v5/dex/market/candles?chainIndex=66&tokenContractAddress=0x382bb369d343125bfb2117af9c149795c6c65c50' \
--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'

Response Example#

200
{
  "code": "0",
  "data": [
    [
      "1597026383085",
      "3.721",
      "3.743",
      "3.677",
      "3.708",
      "22698348.04828491",
      "226348.0482",
      "0"
    ],
    [
      "1597026383085",
      "3.731",
      "3.799",
      "3.494",
      "3.72",
      "67632347.24399722",
      "6767.2439",
      "1"
    ]
  ],
  "msg": ""
}