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

# Industry Constituents

> Get list of stocks belonging to a specific industry by industry name and market area (cn/hk/us). Returns stock symbols, names, and industry classification details

## 查询行业成分股

**URL:** `/v1/stock/industry-constituents`\
**方法:** `POST`\
**描述:** 根据市场和行业名称查询行业成分股列表。

### 请求参数

| 参数名    | 类型     | 必填 | 描述                                                        |
| ------ | ------ | -- | --------------------------------------------------------- |
| market | string | 是  | 股票市场：cn（中国）、hk（香港）、us（美国）                                 |
| name   | string | 是  | 行业名称                                                      |
| type   | string | 否  | 行业分类类型：sw（申万）、wind、hs（恒生）、GICS。默认：CN 用申万，HK 用恒生，US 用 GICS |

### 响应参数

| 参数名     | 类型      | 描述       |
| ------- | ------- | -------- |
| status  | integer | HTTP 状态码 |
| code    | integer | 业务状态码    |
| message | string  | 响应消息     |
| data    | object  | 响应数据     |

#### data 对象结构

| 参数名   | 类型    | 描述    |
| ----- | ----- | ----- |
| items | array | 成分股列表 |

#### 成分股对象结构

| 参数名                           | 类型     | 描述     |
| ----------------------------- | ------ | ------ |
| symbol                        | string | 股票代码   |
| market                        | string | 股票市场   |
| name                          | string | 公司名称   |
| type\_name                    | string | 分类类型名称 |
| industry\_one\_level\_name    | string | 一级行业名称 |
| industry\_second\_level\_name | string | 二级行业名称 |
| industry\_third\_level\_name  | string | 三级行业名称 |

### 示例代码

#### cURL 示例

```bash theme={null}
curl -X POST "https://api.reportify.cn/v1/stock/industry-constituents" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "market": "cn",
    "name": "军工",
    "type": "sw"
  }'
```

#### Python 示例

```python theme={null}
import requests

url = "https://api.reportify.cn/v1/stock/industry-constituents"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "market": "cn",
    "name": "军工",
    "type": "sw"
}

response = requests.post(url, headers=headers, json=data)
result = response.json()

print(f"状态码: {result['status']}")
print(f"成分股数量: {len(result['data']['items'])}")

for item in result['data']['items'][:5]:  # 打印前5个
    print(f"\n股票代码: {item['symbol']}")
    print(f"公司名称: {item['name']}")
    print(f"一级行业: {item['industry_one_level_name']}")
    print(f"二级行业: {item['industry_second_level_name']}")
    print(f"三级行业: {item['industry_third_level_name']}")
```

#### TypeScript 示例

```typescript theme={null}
const response = await fetch('https://api.reportify.cn/v1/stock/industry-constituents', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    market: 'cn',
    name: '军工',
    type: 'sw'
  })
});

const result = await response.json();
console.log(`成分股数量: ${result.data.items.length}`);
```

### 响应示例

#### 成功响应

```json theme={null}
{
  "status": 200,
  "code": 0,
  "message": "",
  "data": {
    "items": [
      {
        "symbol": "600760",
        "market": "cn",
        "name": "中航沈飞",
        "type_name": "申万2021行业",
        "industry_one_level_name": "国防军工",
        "industry_second_level_name": "航空装备",
        "industry_third_level_name": "航空装备"
      },
      {
        "symbol": "600893",
        "market": "cn",
        "name": "航发动力",
        "type_name": "申万2021行业",
        "industry_one_level_name": "国防军工",
        "industry_second_level_name": "航空装备",
        "industry_third_level_name": "航空装备"
      },
      {
        "symbol": "002013",
        "market": "cn",
        "name": "中航机电",
        "type_name": "申万2021行业",
        "industry_one_level_name": "国防军工",
        "industry_second_level_name": "航空装备",
        "industry_third_level_name": "航空装备"
      }
    ]
  }
}
```

#### 成功响应（无数据）

```json theme={null}
{
  "status": 200,
  "code": 0,
  "message": "",
  "data": {
    "items": []
  }
}
```

### 行业分类类型说明

| type 值 | 适用市场 | 说明                  |
| ------ | ---- | ------------------- |
| sw     | cn   | 申万行业分类（推荐用于 A 股）    |
| wind   | cn   | Wind 行业分类           |
| hs     | hk   | 恒生行业分类（推荐用于港股）      |
| GICS   | us   | GICS 全球行业分类（推荐用于美股） |

### 注意事项

* **market 参数值**：
  * `cn` - 中国 A 股市场
  * `hk` - 香港股票市场
  * `us` - 美国股票市场
* **type 参数**：可选参数，不提供时会根据市场自动选择默认分类类型
* **行业名称匹配**：name 参数支持模糊匹配，例如输入"军工"可以匹配"国防军工"
* **空响应**：如果 `data.items` 为空数组，说明没有找到匹配的行业成分股


## OpenAPI

````yaml POST /v1/stock/industry-constituents
openapi: 3.1.0
info:
  title: Reportify API
  version: 1.0.0
  description: API documentation for Reportify's document management and search services.
servers:
  - url: https://api.reportify.cn
    description: Production server
security:
  - BearerAuth: []
paths:
  /v1/stock/industry-constituents:
    post:
      tags:
        - openapi-stock-tools
      summary: Industry Constituents
      description: >-
        Get list of stocks belonging to a specific industry by industry name and
        market area (cn/hk/us). Returns stock symbols, names, and industry
        classification details
      operationId: industry_constituents_reportify_api_v1_stock_industry_constituents_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IndustryConstituentsInput'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockAPIResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    IndustryConstituentsInput:
      properties:
        market:
          type: string
          enum:
            - cn
            - hk
            - us
          title: Market
          description: 'Stock market: cn (China), hk (Hong Kong), or us (United States)'
          example: cn
        name:
          type: string
          title: Name
          description: Industry name
          example: 军工
        type:
          type: string
          title: Type
          description: >-
            Industry classification type: sw (申万), wind, hs (恒生), GICS. Default:
            sw for CN, hs for HK, GICS for US
          example: sw
      type: object
      required:
        - market
        - name
      title: IndustryConstituentsInput
      description: Input schema for industry constituents query
    StockAPIResponse:
      properties:
        status:
          type: integer
          title: Status
          description: HTTP status code
        code:
          type: integer
          title: Code
          description: Response code (0 for success)
        message:
          type: string
          title: Message
          description: Response message
        data:
          type: object
          title: Data
          description: Response data (structure varies by endpoint)
      type: object
      title: StockAPIResponse
      description: Generic response wrapper from stock API
    ErrorResponse:
      properties:
        status:
          type: integer
          title: Status
          description: HTTP status code
        code:
          type: integer
          title: Code
          description: Error code
        message:
          type: string
          title: Message
          description: Error message
      type: object
      title: ErrorResponse
      description: Standard error response
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your Bearer token

````