> ## 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 股、港股、美股） | ✅ |
| 企業版 | ✅ |

## 注意事項

* 此接口按 `market` 查詢，不使用股票代碼；返回的 `industry_counter_id` 可用於行業分類層級接口。
* `market` 不區分大小寫，文檔中的市場代碼統一使用大寫形式。

## 支持的市場

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

## 請求參數

| 參數 | 是否必須 | 說明 |
| - | :-: | - |
| `market` | 是 | 市場代碼：`US` 美股、`HK` 港股、`CN` A股 |
| `limit` | 否 | 返回條數，默認 50，范圍 `1–200` |

## 請求示例

```bash theme={null}
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://api.tickdb.ai/v1/fundamentals/industries/rank?market=US&limit=50"
```

## 返回字段說明

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

| 字段 | 說明 |
| - | - |
| market | 查詢市場。 |
| indicator | 排行指標。 |
| sort\_type | 排序方式。 |
| items | 行業指標排行列表。 |
| └─ industry\_counter\_id | 行業節點 ID。 |
| └─ industry\_name | 行業名稱。 |
| └─ rank | 名次。 |
| └─ value | 行業總市值。 |
| └─ change\_percent | 漲跌幅。 |

返回行業 ID、行業名稱、排名、行業總市值及變化率；行業 ID 可用於查詢行業分類層級。


## OpenAPI

````yaml openapi.zh-Hant.yaml GET /v1/fundamentals/industries/rank
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/rank:
    get:
      tags:
        - fundamentals-valuation-industry
      summary: 行業指標排行
      description: 查詢指定市場按行業指標排序的結果。
      operationId: getFundamentalsIndustriesRank
      parameters:
        - $ref: '#/components/parameters/RequiredMarketQuery'
        - $ref: '#/components/parameters/IndustryRankLimitQuery'
      responses:
        '200':
          $ref: '#/components/responses/IndustriesRankResponse'
        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股
    IndustryRankLimitQuery:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 200
        default: 50
      description: 返回條數，默認 50，范圍 `1–200`
  responses:
    IndustriesRankResponse:
      description: 行業指標排行回應。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/IndustriesRankEnvelope'
    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:
    IndustriesRankEnvelope:
      allOf:
        - $ref: '#/components/schemas/SuccessEnvelope'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/IndustriesRankData'
    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`。
    IndustriesRankData:
      type: object
      required:
        - market
        - indicator
        - sort_type
        - items
      properties:
        market:
          type: string
          description: 查詢市場。
        indicator:
          type: string
          description: 排行指標。
        sort_type:
          type: string
          description: 排序方式。
        items:
          type: array
          description: 行業指標排行列表。
          items:
            $ref: '#/components/schemas/IndustryRankItem'
      additionalProperties: true
    IndustryRankItem:
      type: object
      required:
        - industry_counter_id
        - industry_name
        - rank
        - value
        - change_percent
      properties:
        industry_counter_id:
          type: string
          description: 行業節點 ID。
        industry_name:
          type: string
          description: 行業名稱。
        rank:
          type: integer
          description: 名次。
        value:
          type:
            - string
            - number
          description: 行業總市值。
        change_percent:
          type:
            - string
            - number
            - 'null'
          description: 漲跌幅。
      additionalProperties: true
  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.