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/v6/dex/market/candles
Request Parameters#
| Parameter | Type | Required | Description | 
|---|---|---|---|
| chainIndex | String | Yes | Unique identifier for the chain. e.g., 1: Ethereum.See more here. | 
| tokenContractAddress | String | Yes | Token contract address,for EVM please pass all-lowercase addresses (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50) | 
| after | String | No | Pagination of data to return records earlier than the requested ts. | 
| before | String | No | Pagination of data to return records newer than the requested ts. The latest data will be returned when using before individually | 
| bar | String | No | Bar 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] | 
| limit | String | No | Number of results per request. The maximum is 299. The default is 100. | 
Response Parameters#
| Parameter | Type | Description | 
|---|---|---|
| ts | String | Opening time of the candlestick, Unix timestamp format in milliseconds, e.g. 1597026383085 | 
| o | String | Open price | 
| h | String | Highest price | 
| l | String | Lowest price | 
| c | String | Close price | 
| vol | String | Trading volume, with a unit of base currency. | 
| volUsd | String | Trading volume, with a unit of usd. | 
| confirm | String | The state of candlesticks. 0represents that it is uncompleted,1represents 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/v6/dex/market/candles?chainIndex=66&tokenContractAddress=0x382bb369d343125bfb2117af9c149795c6c65c50' \
--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": ""
}
