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

# 批量查询 K线数据



## OpenAPI

````yaml /zh-Hans/api-reference/openapi.json get /v1/klines/batch
openapi: 3.1.0
info:
  title: TickFlow 行情数据 API
  description: |-
    高性能行情数据服务，支持 A股、ETF、美股、港股。

    ## 认证方式

    所有接口需要通过 `x-api-key` 请求头传递 API Key 进行认证。

    ## 速率限制

    根据 API Key 配置的权限，可能会有请求频率和配额限制。

    ## 批量查询

    部分接口同时支持 GET 和 POST 方法：
    - **GET**: 通过 URL 参数传递，适合少量数据
    - **POST**: 通过 JSON Body 传递，适合大批量查询，不受 URL 长度限制

    ## K线周期

    支持的周期：1m, 5m, 10m, 15m, 30m, 60m, 1d, 1w, 1M, 1Q, 1Y
    - 日内周期(5m/15m/30m/60m)从1m数据聚合
    - 周线(1w)/月线(1M)/季线(1Q)/年线(1Y)从日线聚合
    - intraday 接口当前为 Beta 版本
  contact:
    name: TickFlow Team
  license:
    name: ''
  version: 1.0.0
servers:
  - url: https://api.tickflow.org
security:
  - api_key: []
paths:
  /v1/klines/batch:
    get:
      tags:
        - K线数据
      summary: 批量查询 K线数据
      operationId: get_klines_batch
      parameters:
        - name: symbols
          in: query
          description: 标的代码，逗号分隔, 例如 "600000.SH,000001.SZ"
          required: true
          schema:
            type: string
        - name: period
          in: query
          description: 周期
          required: false
          schema:
            $ref: '#/components/schemas/Period'
        - name: count
          in: query
          description: 返回的K线数量 (默认100, 最大10000)
          required: false
          schema:
            type: integer
            minimum: 0
        - name: start_time
          in: query
          description: 开始时间(毫秒时间戳)
          required: false
          schema:
            type:
              - integer
              - 'null'
            format: int64
        - name: end_time
          in: query
          description: 结束时间(毫秒时间戳)
          required: false
          schema:
            type:
              - integer
              - 'null'
            format: int64
        - name: adjust
          in: query
          description: 复权类型
          required: false
          schema:
            $ref: '#/components/schemas/AdjustType'
      responses:
        '200':
          description: 查询成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KlinesBatchResponse'
        '400':
          description: 参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          description: 认证失败
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '403':
          description: 无权限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      security:
        - api_key: []
components:
  schemas:
    Period:
      type: string
      description: K线周期
      enum:
        - 1m
        - 5m
        - 10m
        - 15m
        - 30m
        - 60m
        - 1d
        - 1w
        - 1M
        - 1Q
        - 1Y
    AdjustType:
      type: string
      description: 复权类型
      enum:
        - forward
        - backward
        - forward_additive
        - backward_additive
        - none
    KlinesBatchResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/CompactKlineData'
          propertyNames:
            type: string
    ApiError:
      type: object
      description: API 错误响应体
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码 (如 "INVALID_PERIOD", "SYMBOL_NOT_FOUND")
          example: INVALID_PERIOD
        details:
          description: 详细信息 (可选，用于调试)
        message:
          type: string
          description: 错误消息 (人类可读)
          example: 'Invalid period: 2d'
    CompactKlineData:
      type: object
      description: 紧凑列式K线数据（用于高效传输）
      required:
        - timestamp
        - open
        - high
        - low
        - close
        - volume
        - amount
      properties:
        amount:
          type: array
          items:
            type: number
            format: double
          description: 成交额
        close:
          type: array
          items:
            type: number
            format: double
          description: 收盘价
        high:
          type: array
          items:
            type: number
            format: double
          description: 最高价
        low:
          type: array
          items:
            type: number
            format: double
          description: 最低价
        open:
          type: array
          items:
            type: number
            format: double
          description: 开盘价
        open_interest:
          type: array
          items:
            type: number
            format: double
          description: 持仓量
        prev_close:
          type: array
          items:
            type: number
            format: double
          description: 前收盘价
        settlement_price:
          type: array
          items:
            type: number
            format: double
          description: 结算价
        timestamp:
          type: array
          items:
            type: integer
            format: int64
          description: 时间戳 (毫秒)
        volume:
          type: array
          items:
            type: integer
            format: int64
          description: 成交量
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: x-api-key

````