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

# 行业分类层级

> 查询指定行业所属的顶层分类及下级行业分类。

## 套餐权限

| 套餐 | 可用 |
| - | :-: |
| 免费版 | ❌ |
| 基础版 | ❌ |
| 专业版 | ✅ |
| 全量套餐（A 股、港股、美股） | ✅ |
| 企业版 | ✅ |

## 注意事项

* `industry_counter_id` 可从行业指标排行获取；不同市场的行业节点不能混用。
* `market` 不区分大小写，文档中的市场代码统一使用大写形式。

## 支持的市场

| 市场 | 示例 |
| - | - |
| 美股 | US |
| 港股 | HK |
| A股 | CN |

## 请求参数

| 参数 | 是否必须 | 说明 |
| - | :-: | - |
| `market` | 是 | 市场代码：`US` 美股、`HK` 港股、`CN` A股 |
| `industry_counter_id` | 是 | 行业节点 ID，可从行业指标排行接口获取 |

## 请求示例

```bash theme={null}
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://api.tickdb.ai/v1/fundamentals/industries/tree?market=US&industry_counter_id=BK%2FUS%2FIN00260"
```

## 返回字段说明

以下列出 `data` 中的字段；外层 `code=0` 表示成功。

| 字段 | 说明 |
| - | - |
| market | 查询市场。 |
| industry\_counter\_id | 行业节点 ID。 |
| top | 所属顶层行业分类。 |
| └─ name | 顶层行业名称。 |
| └─ market | 顶层行业市场。 |
| chain | 当前行业及其下级分类组成的层级结构。 |
| └─ name | 节点名称。 |
| └─ counter\_id | 行业节点 ID。 |
| └─ level | 节点层级。 |
| └─ parent\_code | 父节点代码。 |
| └─ market | 所属市场。 |
| └─ stock\_num | 股票数量。 |
| └─ chg | 变动值。 |
| └─ ytd\_chg | 年初至今变动值。 |
| └─ symbol | 节点关联代码。 |
| └─ sharelist\_id | 股票列表 ID。 |
| └─ next | 下级行业分类列表；元素递归使用相同节点结构。 |

返回指定行业的顶层归属、当前分类和下级分类，便于查看行业分类关系。


## OpenAPI

````yaml openapi.yaml GET /v1/fundamentals/industries/tree
openapi: 3.1.0
info:
  title: TickDB API
  description: TickDB 统一实时行情数据 API，提供 REST 和 WebSocket 接入。
  version: 1.0.3
  contact:
    email: support@tickdb.ai
servers:
  - url: https://api.tickdb.ai
    description: 生产环境
security:
  - ApiKeyAuth: []
paths:
  /v1/fundamentals/industries/tree:
    get:
      tags:
        - fundamentals-valuation-industry
      summary: 行业分类层级
      description: 查询指定行业所属的顶层分类及下级行业分类。
      operationId: getFundamentalsIndustriesTree
      parameters:
        - $ref: '#/components/parameters/RequiredMarketQuery'
        - $ref: '#/components/parameters/IndustryCounterIDQuery'
      responses:
        '200':
          $ref: '#/components/responses/IndustriesTreeResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  parameters:
    RequiredMarketQuery:
      name: market
      in: query
      required: true
      schema:
        type: string
        enum:
          - US
          - HK
          - CN
      description: 市场代码：`US` 美股、`HK` 港股、`CN` A股
    IndustryCounterIDQuery:
      name: industry_counter_id
      in: query
      required: true
      schema:
        type: string
      description: 行业节点 ID，可从行业指标排行接口获取
  responses:
    IndustriesTreeResponse:
      description: 行业分类层级响应。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/IndustriesTreeEnvelope'
    ErrorResponse:
      description: >-
        错误响应。常见 HTTP 状态包括
        400（参数错误）、401（鉴权失败）、403（权限或配额限制）、404（无匹配数据）、429（请求频率限制）和 503（服务暂不可用）。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            missingAPIKey:
              summary: 缺少 API Key
              value:
                code: '1002'
                message: API key is required. Provide via X-API-Key header
                error: '1002'
            missingKind:
              summary: 缺少必填参数
              value:
                code: 40001
                message: kind is required
                data: null
            endpointForbidden:
              summary: API Key 无权访问该接口
              value:
                code: 3009
                message: This endpoint is not allowed for your API key
                data: null
            marketForbidden:
              summary: API Key 未开放该市场
              value:
                code: 3010
                message: Fundamentals market not allowed for your API key
                data:
                  market: US
            noAvailableSource:
              summary: 数据暂不可用
              value:
                code: 5003
                message: Data is temporarily unavailable
                data: null
            notFound:
              summary: 无匹配数据
              value:
                code: 40404
                message: shareholder detail not found
                data: null
            businessNoData:
              summary: 查询条件无有效业务数据
              value:
                code: 40405
                message: valuation time series not found
                data: null
  schemas:
    IndustriesTreeEnvelope:
      allOf:
        - $ref: '#/components/schemas/SuccessEnvelope'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/IndustriesTreeData'
    ErrorEnvelope:
      type: object
      required:
        - code
        - message
      properties:
        code:
          description: TickDB API 业务错误码；可能为整数或字符串，客户端应归一化为字符串后比较。
          oneOf:
            - type: integer
            - type: string
        message:
          type: string
          description: 错误说明。
        error:
          type: string
          description: 兼容错误标识；仅部分错误响应返回。
        data:
          description: 可选的错误上下文；可能为 null、对象或数组。
          oneOf:
            - type: 'null'
            - type: object
              additionalProperties: true
            - type: array
              items: {}
    SuccessEnvelope:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          const: 0
          description: 业务状态码，成功为 0。
    IndustriesTreeData:
      type: object
      required:
        - market
        - industry_counter_id
        - top
        - chain
      properties:
        market:
          type: string
          description: 市场。
        industry_counter_id:
          type: string
          description: 行业 ID。
        top:
          $ref: '#/components/schemas/IndustryTop'
        chain:
          $ref: '#/components/schemas/IndustryChainNode'
      additionalProperties: true
    IndustryTop:
      type: object
      required:
        - name
        - market
      properties:
        name:
          type: string
          description: 节点名称。
        market:
          type: string
          description: 市场。
      additionalProperties: false
    IndustryChainNode:
      type: object
      required:
        - name
        - level
        - market
        - counter_id
        - next
      properties:
        name:
          type: string
          description: 行业名称。
        level:
          type: integer
          description: 层级。
        market:
          type: string
          description: 市场。
        counter_id:
          type: string
          description: 行业 counter ID。
        parent_code:
          type: string
          description: 父行业代码。
        sharelist_id:
          type: string
          description: 股票列表 ID。
        symbol:
          type: string
          description: 节点关联代码。
        stock_num:
          type: integer
          minimum: 0
          description: 股票数量。
        chg:
          type:
            - string
            - number
            - 'null'
          description: 变动值。
        ytd_chg:
          type:
            - string
            - number
            - 'null'
          description: 年初至今变动值。
        next:
          type: array
          description: 下一级行业分类节点。
          items:
            $ref: '#/components/schemas/IndustryChainNode'
      additionalProperties: false
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.