Skip to main content

Get K-Line

API Description

This interface allow querying the K-line (candlestick chart) data for the specified instrument(s), including the opening price, closing price, highest price, lowest price and trading volume.

Note: K-line data is accessible via both RESTful and Websocket APIs. This page describes the RESTful API. For information on the Websocket API, please click here

Precautions

  1. This interface returns K-line data for the current time, and the K-line interval may or may not be completed.
  2. If neither the starting nor ending timestamps are specified, by default the interface will return 100 K-lines for each instrument.

Authentication

This is a public interface and does not require authentication. For details on using the RESTful API, please refer to Introduction > Authentication & Code Snippet > Spot > RESTful Public Interface.

Request Method

GET

Endpoint

/api/v1/public?command=returnChartData

Frequency Limit

The frequency limit for this interface is 10 requests/s per IP. In addition to this per-interface limit, a global rate limit is also enforced.

For detailed information on Global rate limits and API Rate Limiting Policy, please refer to the "Frequency Limit" section at click here

Request Parameters

ParameterMandatoryTypeDescription
periodIntegerTrueK-line interval in seconds, i.e.,60: 1-minute,180: 3-minute,300: 5-minute,900: 15-minute,1800: 30-minute,7200: 2-hour,14400: 4-hour
currencyPairStringTrueTrading instrument(s). Multiple tranding instruments allowed, separated by commas.
Example: "BTC_USDT,ETH_USDT"
Note: Max 20 instrument per request
startString/IntegerFalseK-line start time ( Unix timestamp in milliseconds.)
endString/IntegerFalseK-line end time ( Unix timestamp in milliseconds.)

Response Parameters

ParameterTypeDescription
dateLongK-line timestamp
highStringHighest price
lowStringLowest price
openStringOpening price
closeStringClosing price
volumeStringTrading volume
pairStringTrading instrument

Request Example

The following Python code shows how to get the 5-minute k-line data for BTC_USDT and ETH_USDT.

Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Spot > RESTful Public Interface.

api_url= "/api/v1/public?command=returnChartData"
params={
"currencyPair":"BTC_USDT,ETH_USDT",
"period":30,
# "start": "1579238517000",
# "end": "1581916917660"
}
SpotRestfulPublic(api_url, params) # function SpotRestfulPublic() is defined in section (Introduction > Authentication & Code Snippet > Spot > RESTful Public Interface)

Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Spot > RESTful Public Interface.

Response Example

The following is an example response returned by the above Python request. The actual response returns 100 k-line informationn for each instrument. For brevity, only three k-lines for each instrument are shown below:

 {'code': '200',
'data': [{'open': '87610.75', # BTC_USDT
'high': '87614.4',
'low': '87573.42',
'close': '87573.42',
'volume': '10.554',
'pair': 'BTC_USDT',
'date': 1764077100000},
{'open': '87605.86',
'high': '87650.21',
'low': '87516.5',
'close': '87593.07',
'volume': '85.8893',
'pair': 'BTC_USDT',
'date': 1764076800000},,.........
{'open': '88212.98',
'high': '88253.05',
'low': '88165.65',
'close': '88173.03',
'volume': '36.0383',
'pair': 'BTC_USDT',
'date': 1764047400000},
{'open': '2927.57', # ETH_USDT
'high': '2928.05',
'low': '2927.2',
'close': '2927.56',
'volume': '69.016',
'pair': 'ETH_USDT',
'date': 1764077100000},
{'open': '2929.82',
'high': '2930.11',
'low': '2924.49',
'close': '2927.18',
'volume': '295.2313',
'pair': 'ETH_USDT',
'date': 1764076800000},.......
{'open': '2930.78',
'high': '2931.52',
'low': '2928.45',
'close': '2929.39',
'volume': '142.3569',
'pair': 'ETH_USDT',
'date': 1764047400000}],
'msg': 'SUCCESS',
'success': True,
'failed': False}