Skip to main content

GET /kline

Interface Description

This interface can be used to query historical K-lines, but each request can query only one product. It is recommended to cache the queried historical K-lines in a local database. For customers using HTTP interfaces to obtain K-lines, we recommend using /kline together with /batch-kline as follows:
  • First, use the /kline interface to poll historical data and store it in a local database. Later historical data can be obtained directly from the customer’s database without making another interface request.
  • Then, continuously use the /batch-kline interface to batch request the latest 2 K-lines for multiple products and update the database with the data.
This approach can quickly update the latest K-lines while avoiding frequency restrictions caused by frequent historical K-line requests.

Request Frequency

PlanIndividual RequestRequesting Multiple HTTP Interfaces at the Same Time
FreeOne request every 10 seconds1. Only one interface can be requested every 10 seconds.
2. When requesting multiple interfaces, note that the /batch-kline interface requires a 10-second interval.
3. All interfaces combined: maximum 10 requests per minute (one every 6 seconds).
4. Maximum 1,000 requests per day; usage resumes after midnight the next day if exceeded.
BasicOne request per second1. Only one interface can be requested in the same second.
2. When requesting multiple interfaces, note that the /batch-kline interface requires a 3-second interval.
3. All interfaces combined: maximum 60 requests per minute (one per second).
4. Maximum 86,400 requests per day; usage resumes after midnight the next day if exceeded.
PremiumUp to 10 requests per second1. All interfaces combined: up to 10 requests per second.
2. When requesting multiple interfaces, note that the /batch-kline interface requires a 2-second interval.
3. All interfaces combined: maximum 600 requests per minute (10 per second).
4. Maximum 864,000 requests per day; usage resumes after midnight the next day if exceeded.
ProfessionalUp to 20 requests per second1. All interfaces combined: up to 20 requests per second.
2. When requesting multiple interfaces, note that the /batch-kline interface requires a 1-second interval.
3. All interfaces combined: maximum 1,200 requests per minute (20 per second).
4. Maximum 1,728,000 requests per day; usage resumes after midnight the next day if exceeded.
All Hong Kong StocksUp to 20 requests per second1. All interfaces combined: up to 20 requests per second.
2. When requesting multiple interfaces, note that the /batch-kline interface requires a 1-second interval.
3. All interfaces combined: maximum 1,200 requests per minute (20 per second).
4. Maximum 1,728,000 requests per day; usage resumes after midnight the next day if exceeded.
All A SharesUp to 20 requests per second1. All interfaces combined: up to 20 requests per second.
2. When requesting multiple interfaces, note that the /batch-kline interface requires a 1-second interval.
3. All interfaces combined: maximum 1,200 requests per minute (20 per second).
4. Maximum 1,728,000 requests per day; usage resumes after midnight the next day if exceeded.
All US StocksUp to 20 requests per second1. All interfaces combined: up to 20 requests per second.
2. When requesting multiple interfaces, note that the /batch-kline interface requires a 1-second interval.
3. All interfaces combined: maximum 1,200 requests per minute (20 per second).
4. Maximum 1,728,000 requests per day; usage resumes after midnight the next day if exceeded.

Interface Limitations

  1. Be sure to read: HTTP Interface Restrictions
  2. Be sure to read: Error Code Description

API Endpoints

1. US Stocks, Hong Kong Stocks, A Shares, and Major Index Data API Endpoint: 2. Forex, Precious Metals, Cryptocurrencies, Crude Oil, CFD Indices, and Commodities API Endpoint:

Request Examples

1. Request example for US Stocks, Hong Kong Stocks, A Shares, and Major Index Data: When sending a query request, you must include the method name and token information. Example: https://quote.alltick.co/quote-stock-b-api/kline?token=your_token&query=queryData 2. Request example for Forex, Precious Metals, Cryptocurrencies, Crude Oil, CFD Indices, and Commodities: When sending a query request, you must include the method name and token information. Example: https://quote.alltick.co/quote-b-api/kline?token=your_token&query=queryData

Request Parameters

NamePositionTypeRequiredDescription
tokenquerystringNo
queryquerystringNoSee the query request parameter description.

Query Request Parameters

{
  "trace": "3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
  "data": {
    "code": "857.HK",
    "kline_type": 1,
    "kline_timestamp_end": 0,
    "query_kline_num": 2,
    "adjust_type": 0
  }
}
NameTypeRequiredDescription
tracestringYesTrace code used for log lookup. Ensure it is unique for each request.
dataobjectYes
» codestringYesView the code list and select the code you want to query: [Click the code list]
Note: The code value must match the case of the code in the product list.
» kline_typeintegerYesK-line type:
1. 1 is 1-minute K-line, 2 is 5-minute K-line, 3 is 15-minute K-line, 4 is 30-minute K-line, 5 is hourly K-line, 6 is 2-hour K-line (stocks do not support 2-hour K-line), 7 is 4-hour K-line (stocks do not support 4-hour K-line), 8 is daily K-line, 9 is weekly K-line, and 10 is monthly K-line. Note: stocks do not support 2-hour or 4-hour K-lines.
2. The shortest supported K-line is 1 minute.
3. To query yesterday’s closing price, pass 8 for kline_type.
» kline_timestamp_endintegerYesQuery K-lines backward from the specified time.
1. Pass 0 to query K-lines backward from the latest trading day.
2. Pass a timestamp to query K-lines backward from that timestamp.
3. Only forex, precious metals, and cryptocurrencies support timestamp input; stock codes do not.
» query_kline_numintegerYes1. Indicates how many K-lines to query. Each request can query up to 500 K-lines, and you can loop backward by timestamp.
2. This field can be used to query yesterday’s closing price: pass 8 for kline_type and 2 for query_kline_num. Of the 2 returned K-line records, the one with the smaller timestamp is yesterday’s closing price.
» adjust_typeintegerYesAdjustment type. Effective only for stock codes. For example: 0: ex-rights, 1: forward-adjusted. Currently only 0 is supported.

Response Example

{
  "ret": 200,
  "msg": "ok",
  "trace": "3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
  "data": {
    "code": "857.HK",
    "kline_type": 1,
    "kline_list": [
      {
        "timestamp": "1677829200",
        "open_price": "136.421",
        "close_price": "136.412",
        "high_price": "136.422",
        "low_price": "136.407",
        "volume": "0",
        "turnover": "0"
      },
      {
        "timestamp": "1677829260",
        "open_price": "136.412",
        "close_price": "136.401",
        "high_price": "136.415",
        "low_price": "136.397",
        "volume": "0",
        "turnover": "0"
      }
    ]
  }
}

Response Result

Status CodeStatus MeaningDescriptionData Model
200OKOKInline

Response Data Structure

NameTypeRequiredDescription
» retintegertrue
» msgstringtrue
» tracestringtrue
» dataobjecttrue
»» codestringtrueCode
»» kline_typeintegertrueK-line type:
1. 1 is 1-minute K-line, 2 is 5-minute K-line, 3 is 15-minute K-line, 4 is 30-minute K-line, 5 is hourly K-line, 6 is 2-hour K-line (stocks do not support 2-hour K-line), 7 is 4-hour K-line (stocks do not support 4-hour K-line), 8 is daily K-line, 9 is weekly K-line, and 10 is monthly K-line. Note: stocks do not support 2-hour or 4-hour K-lines.
2. The shortest supported K-line is 1 minute.
»» kline_list[object]true
»»» timestampstringtrueTimestamp of the K-line
»»» open_pricestringtrueOpening price of the K-line
»»» close_pricestringtrueClosing price of the K-line:
1. During trading hours, for the latest K-line, this price is also the latest trade price.
2. During market closure, for the latest K-line, this price is the closing price.
»»» high_pricestringtrueHighest price of the K-line
»»» low_pricestringtrueLowest price of the K-line
»»» volumestringtrueTrading quantity of the K-line
»»» turnoverstringtrueTrading amount of the K-line

AllTick Website

Official website: https://alltick.co/

Interface Debug

Open GET /kline Debug Module

Use the debuggable module to fill in parameters and send requests.