Skip to main content

K-line Data

K-line data query service, provides historical K-line queries.

K-line Return Format

All K-line interfaces return a 2D array, each K-line is an array of 12 elements:

IndexFieldTypeDescription
[0]openTimeintegerOpen timestamp (milliseconds)
[1]closeTimeintegerClose timestamp (milliseconds)
[2]openstringOpen price
[3]highstringHigh price
[4]lowstringLow price
[5]closestringClose price
[6]volumestringTrading volume
[7]quoteVolumestringQuote volume
[8]tradesintegerNumber of trades
[9]takerBuyBaseVolumestringTaker buy base volume
[10]takerBuyQuoteVolumestringTaker buy quote volume
[11]isClosedbooleanWhether the K-line is closed

Data is sorted in descending order by time (newest first), including the current unclosed K-line.

Supported Time Intervals

1s · 1m · 3m · 5m · 15m · 30m · 1h · 2h · 4h · 6h · 8h · 12h · 1d · 3d · 1w · 1M


Query K-line Data

Query historical K-line data for a single trading pair, supports two mutually exclusive modes:

  1. Query by quantity: Only pass symbol + interval + limit, returns the latest limit K-lines
  2. Query by time range: Pass symbol + interval + start_time + end_time, returns all K-lines within that time period

⚠️ The limit parameter is mutually exclusive with start_time/end_time, cannot be used together.

API Information

  • Method: GET
  • Path: /api/v1/klines

Request Parameters

ParameterLocationTypeRequiredDescription
symbolquerystringYesTrading pair
intervalquerystringYesTime interval (see table above)
start_timequeryintegerNoStart timestamp (milliseconds), must be used with end_time, mutually exclusive with limit
end_timequeryintegerNoEnd timestamp (milliseconds), must be used with start_time, mutually exclusive with limit
limitqueryintegerNoReturn latest N records, default 500, max 1500, mutually exclusive with start_time/end_time

Request Example

# By quantity
GET /api/v1/klines?symbol=BTC_USDT&interval=1m&limit=100

# By time range
GET /api/v1/klines?symbol=BTC_USDT&interval=1h&start_time=1704067200000&end_time=1704153600000

Success Response

Returns 2D array, each K-line has 12 elements, see "K-line Return Format".

Error Response

HTTP status code is always 200, errors distinguished by code field:

  • 6000-6999: Client errors
  • 7000-7999: Server errors
{
"code": 6001,
"message": "invalid interval"
}

Response Example

[
[
1704153600000,
1704153659999,
"42150.50",
"42180.00",
"42140.00",
"42165.30",
"125.45",
"5289456.75",
2580,
"68.20",
"2876543.21",
false
]
]

Batch Query K-line Data

Query the latest K-line data for multiple trading pairs at once, all trading pairs use the same time interval and limit parameter.

API Information

  • Method: GET
  • Path: /api/v1/klines/batch

Request Parameters

ParameterLocationTypeRequiredDescription
symbolsquerystringYesTrading pair list, comma-separated, max 20
intervalquerystringYesTime interval (see table above)
limitqueryintegerNoReturn latest N records for each trading pair, default 500, max 1500

Request Example

GET /api/v1/klines/batch?symbols=BTC_USDT,ETH_USDT&interval=1m&limit=100

Response Fields

Returns JSON object:

  • key: Trading pair name
  • value: K-line 2D array for that trading pair (same format as single trading pair interface)

K-lines for each trading pair are sorted in descending order by time (newest first), including the current unclosed K-line.

Response Example

{
"BTC_USDT": [
[1704153600000, 1704153659999, "42150.50", "42180.00", "42140.00", "42165.30", "125.45", "5289456.75", 2580, "68.20", "2876543.21", false]
],
"ETH_USDT": [
[1704153600000, 1704153659999, "2250.10", "2255.80", "2248.00", "2252.30", "980.50", "2208756.10", 1850, "520.10", "1172345.60", false]
]
}