> ## 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.

# 實時 K 線

> 獲取當前時間週期內正在形成並實時更新的 K 線數據。

## 注意事項

* 本接口返回當前週期內正在形成的K線數據，數據會隨著成交持續更新
* 適用於實時行情圖表展示、當前價格監控、分時動態更新
* 不建議用於歷史回測、技術指標統計、固定數據存儲
* 若需查詢已結束週期的數據，請使用歷史K線：`/v1/market/kline`

## 支持的市場

**外匯**、**貴金屬**、**指數**、**美股**、**港股**、**A股**、**加密貨幣**

示例：

* 外匯：EURUSD、GBPUSD、USDJPY
* 貴金屬：XAUUSD、XAGUSD
* 指數：SPX、NDX、DJI
* 美股：AAPL.US、TSLA.US、MSFT.US
* 港股：700.HK、9988.HK、3690.HK
* A股：600519.SH、000001.SZ、920186.BJ
* 加密貨幣：BTCUSDT、ETHUSDT、ADAUSDT

## 請求參數

| 參數名      | 是否必須 | 描述                                                                                             |
| -------- | ---- | ---------------------------------------------------------------------------------------------- |
| symbols  | 是    | 交易產品代碼，多個用逗號分隔，例如：AAPL.US,00700.HK                                                             |
| interval | 是    | K線週期，可選值：1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 1d, 1w, 1M                                          |
| type     | 否    | 產品類型，可選。代碼無歧義時無需傳遞；若返回 `AMBIGUOUS_SYMBOL` 錯誤，按提示傳入對應值即可。可選值：`stock`、`indices`、`crypto`、`forex` |

## 返回字段說明

| 字段               | 說明        |
| ---------------- | --------- |
| symbol           | 交易產品      |
| interval         | K線週期      |
| klines           | K線數據數組    |
| └─ time          | K線時間戳（毫秒） |
| └─ open          | 開盤價       |
| └─ high          | 最高價       |
| └─ low           | 最低價       |
| └─ close         | 收盤價       |
| └─ volume        | 成交量       |
| └─ quote\_volume | 成交額       |


## OpenAPI

````yaml GET /v1/market/kline/latest
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, and Crypto via REST and WebSocket.
  version: 1.0.1
  contact:
    email: support@tickdb.ai
servers:
  - url: https://api.tickdb.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v1/market/kline/latest:
    get:
      summary: Latest K-line Data
      description: Get the latest candlestick data for one or more symbols
      parameters:
        - name: symbols
          in: query
          required: true
          description: Comma-separated symbols (e.g., AAPL.US,00700.HK)
          schema:
            type: string
            default: AAPL.US,00700.HK
            example: AAPL.US,00700.HK
        - name: interval
          in: query
          required: true
          description: K-line interval
          schema:
            type: string
            enum:
              - 1m
              - 3m
              - 5m
              - 15m
              - 30m
              - 1h
              - 2h
              - 4h
              - 1d
              - 1w
              - 1M
            default: 3m
            example: 3m
        - 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
            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: array
                    items:
                      type: object
                      properties:
                        symbol:
                          type: string
                        interval:
                          type: string
                        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
                    example:
                      - symbol: AAPL.US
                        interval: 3m
                        klines:
                          - time: 1773259020000
                            open: '260.86'
                            high: '261.05'
                            low: '260.7'
                            close: '260.81'
                            volume: '963419'
                            quote_volume: '251311057.55'
                      - symbol: 00700.HK
                        interval: 3m
                        klines:
                          - time: 1773293400000
                            open: '542.5'
                            high: '544.5'
                            low: '542'
                            close: '544.5'
                            volume: '80300'
                            quote_volume: '43656433.33'
        '400':
          description: Bad Request - Invalid parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    example: 400
                  message:
                    type: string
                    example: Invalid parameters
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    example: 401
                  message:
                    type: string
                    example: Unauthorized
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````