> ## 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
* 中国期货：BU2609、IC2606、AP8888
* 加密货币：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`、`futures` |

## 返回字段说明

| 字段                | 说明          |
| ----------------- | ----------- |
| symbol            | 交易产品        |
| type              | 产品类型        |
| interval          | K线周期        |
| klines            | K线数据数组      |
| └─ time           | K线时间戳（毫秒）   |
| └─ open           | 开盘价         |
| └─ high           | 最高价         |
| └─ low            | 最低价         |
| └─ close          | 收盘价         |
| └─ volume         | 成交量         |
| └─ quote\_volume  | 成交额，期货通常不返回 |
| └─ open\_interest | 持仓量，仅期货返回   |


## 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, 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/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
              - 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: array
                    items:
                      type: object
                      properties:
                        symbol:
                          type: string
                        type:
                          type: string
                          enum:
                            - stock
                            - indices
                            - crypto
                            - forex
                            - futures
                        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
                                description: Trading amount; normally omitted for futures
                              open_interest:
                                type: string
                                description: Open interest; returned for futures
                    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

````