> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tickdb.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Historical K-Line

> Get historical K-line data for completed time periods.

## Notes

* This endpoint returns historical K-line data for completed periods, data is fixed and will not change
* Suitable for strategy backtesting, technical indicator calculation, and data archiving
* For real-time K-line data in the current period, use Real-time K-Line: `/v1/market/kline/latest`

## Supported Markets

**Forex**, **Metals**, **Indices**, **US Stocks**, **HK Stocks**, **A-Shares**, **China Futures**, **Crypto**

Examples:

* Forex: EURUSD, GBPUSD, USDJPY
* Metals: XAUUSD, XAGUSD
* Indices: SPX, NDX, DJI
* US Stocks: AAPL.US, TSLA.US, MSFT.US
* HK Stocks: 700.HK, 9988.HK, 3690.HK
* A-Shares: 600519.SH, 000001.SZ, 920186.BJ
* China Futures: BU2609, IC2606, AP8888
* Crypto: BTCUSDT, ETHUSDT, ADAUSDT

## Request Parameters

| Parameter   | Required | Description                                                                                                                                                                                               |
| ----------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| symbol      | Yes      | Trading symbol code                                                                                                                                                                                       |
| interval    | Yes      | K-line period, options: 1m, 5m, 15m, 30m, 1h, 2h, 4h, 1d, 1w, 1M                                                                                                                                          |
| limit       | No       | Number of records, default 100, max 1000                                                                                                                                                                  |
| start\_time | No       | Start timestamp (milliseconds)                                                                                                                                                                            |
| end\_time   | No       | End timestamp (milliseconds)                                                                                                                                                                              |
| type        | No       | Symbol type, optional. Not required when the symbol is unambiguous; if the API returns an `AMBIGUOUS_SYMBOL` error, pass the value as indicated. Values: `stock`, `indices`, `crypto`, `forex`, `futures` |

## Response Fields

| Field             | Description                                  |
| ----------------- | -------------------------------------------- |
| symbol            | Trading Symbol                               |
| type              | Product type                                 |
| interval          | K-line period                                |
| klines            | K-line data array                            |
| └─ time           | K-line timestamp (milliseconds)              |
| └─ open           | Opening price                                |
| └─ high           | Highest price                                |
| └─ low            | Lowest price                                 |
| └─ close          | Closing price                                |
| └─ volume         | Trading volume                               |
| └─ quote\_volume  | Trading amount; normally omitted for futures |
| └─ open\_interest | Open interest; returned for futures          |


## OpenAPI

````yaml GET /v1/market/kline
openapi: 3.0.0
info:
  title: TickDB API
  description: >-
    Unified real-time market data API — one connection for Forex, indices, US
    stocks, HK stocks, A-shares, China futures, and Crypto via REST and
    WebSocket.
  version: 1.0.2
  contact:
    email: support@tickdb.ai
servers:
  - url: https://api.tickdb.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v1/market/kline:
    get:
      summary: K-line (Candlestick) Data
      description: Get historical candlestick data for a symbol
      parameters:
        - name: symbol
          in: query
          required: true
          description: Trading symbol
          schema:
            type: string
            default: 700.HK
            example: 700.HK
        - name: interval
          in: query
          required: true
          description: K-line interval
          schema:
            type: string
            enum:
              - 1m
              - 5m
              - 15m
              - 30m
              - 1h
              - 2h
              - 4h
              - 1d
              - 1w
              - 1M
            default: 1h
            example: 1h
        - name: limit
          in: query
          required: false
          description: Number of records (default 100, max 1000)
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            example: 100
        - name: start_time
          in: query
          required: false
          description: Start timestamp in milliseconds
          schema:
            type: integer
            example: 1703123456789
        - name: end_time
          in: query
          required: false
          description: End timestamp in milliseconds
          schema:
            type: integer
            example: 1703209856789
        - name: type
          in: query
          required: false
          description: >-
            Symbol type, optional. Not required when the symbol is unambiguous;
            if the API returns an AMBIGUOUS_SYMBOL error, pass the value as
            indicated
          schema:
            type: string
            enum:
              - stock
              - indices
              - crypto
              - forex
              - futures
            example: stock
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    example: 0
                  message:
                    type: string
                    example: success
                  data:
                    type: object
                    properties:
                      symbol:
                        type: string
                        example: 700.HK
                      type:
                        type: string
                        enum:
                          - stock
                          - indices
                          - crypto
                          - forex
                          - futures
                      interval:
                        type: string
                        example: 1h
                      klines:
                        type: array
                        items:
                          type: object
                          properties:
                            time:
                              type: integer
                            open:
                              type: string
                            high:
                              type: string
                            low:
                              type: string
                            close:
                              type: string
                            volume:
                              type: string
                            quote_volume:
                              type: string
                              description: Trading amount; normally omitted for futures
                            open_interest:
                              type: string
                              description: Open interest; returned for futures
                        example:
                          - time: 1773291600000
                            open: '545.5'
                            high: '546.5'
                            low: '541.5'
                            close: '543.5'
                            volume: '1549300'
                            quote_volume: '842560983.33'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````