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

# 分类体系

> 用于准确认证要求的物品分类系统。

## 概述

Legitmark 使用四级层次分类系统。每个级别决定认证要求和服务选择：

```mermaid theme={null}
graph TD
    A["类别<br/><small>顶级分类</small>"] --> B1["箱包"]
    A --> B2["手表"]
    
    B1 --> C1["托特包"]
    B1 --> C2["手拿包"]
    B2 --> C3["奢侈手表"]
    B2 --> C4["运动手表"]
    
    C1 --> D1["路易威登"]
    C1 --> D2["香奈儿"]
    C3 --> D3["劳力士"]
    C3 --> D4["路易威登"]
    
    D1 --> E1["Neverfull MM"]
    D1 --> E2["Speedy 30"]
    D3 --> E3["Submariner"]
    D4 --> E4["Tambour"]
    
    style A fill:#e1f5fe
    style B1 fill:#f3e5f5
    style B2 fill:#f3e5f5
    style C1 fill:#fff3e0
    style C2 fill:#fff3e0
    style C3 fill:#fff3e0
    style C4 fill:#fff3e0
    style D1 fill:#e8f5e8
    style D2 fill:#e8f5e8
    style D3 fill:#e8f5e8
    style D4 fill:#e8f5e8
    style E1 fill:#fce4ec
    style E2 fill:#fce4ec
    style E3 fill:#fce4ec
    style E4 fill:#fce4ec
```

**层次级别：**

* **第 1 级：类别**（必需）- 广泛的产品分类
* **第 2 级：类型**（必需）- 具体的产品子类别
* **第 3 级：品牌**（可选）- 制造商或设计师
* **第 4 级：型号**（可选）- 具体的产品变体

## 获取分类体系数据

### 完整树

一次请求获取所有内容用于初始设置：

**API 参考：** [获取分类体系树](/api-reference/categories/get-taxonomy-tree) - `GET /api/v2/categories/tree`

<CodeGroup>
  ```javascript HTTP theme={null}
  const response = await fetch('https://api.legitmark.com/api/v2/categories/tree?active_only=true', {
    headers: { 'Authorization': 'Bearer leo_xxxxxxxxx' }
  });
  const { data: categories, metadata } = await response.json();
  ```

  ```typescript SDK theme={null}
  const { data: categories, metadata } = await legitmark.taxonomy.getTree({ activeOnly: true });

  console.log(`${metadata.total_categories} categories, ${metadata.total_types} types`);
  for (const category of categories) {
    console.log(`${category.name}: ${category.types?.length} types`);
  }
  ```
</CodeGroup>

<Tip>
  分类体系树包括类别和类型（必需），以及品牌和型号（可选）。**强烈建议匹配品牌和型号**以根据完整的分类体系深度获得更具体的图片要求。如果未匹配品牌和型号，可能需要额外的照片进行认证。
</Tip>

### 关键筛选端点

* [获取类型的品牌](/api-reference/types/get-brands-for-type)
* [获取品牌的型号](/api-reference/brands/get-models-for-brand)

### 其他端点

* [列出品牌](/api-reference/brands/list-brands)
* [获取类别的类型](/api-reference/categories/get-types-for-category)
* [列出类别](/api-reference/categories/list-categories)
* [获取单个类别](/api-reference/categories/get-single-category)
* [列出类型](/api-reference/types/list-types)
* [获取单个类型](/api-reference/types/get-single-type)
* [列出型号](/api-reference/models/list-models)

## 集成方法

### 直接使用我们的分类体系

向您的用户展示 Legitmark 类别：

<CodeGroup>
  ```javascript HTTP theme={null}
  const response = await fetch('https://api.legitmark.com/api/v2/categories?active_only=true', {
    headers: { 'Authorization': 'Bearer leo_xxxxxxxxx' }
  });
  const { data } = await response.json();

  data.forEach(category => {
    console.log(category.name); // "箱包", "鞋类" 等
  });
  ```

  ```typescript SDK theme={null}
  const { data: categories } = await legitmark.taxonomy.getCategories();

  for (const category of categories) {
    console.log(category.name);
  }
  ```
</CodeGroup>

### 获取选定类型的品牌

<CodeGroup>
  ```javascript HTTP theme={null}
  const response = await fetch(
    `https://api.legitmark.com/api/v2/types/${typeUuid}/brands`,
    { headers: { 'Authorization': 'Bearer leo_xxxxxxxxx' } }
  );
  const { data: brands } = await response.json();
  ```

  ```typescript SDK theme={null}
  const { data: brands } = await legitmark.taxonomy.getBrandsForType(typeUuid);

  for (const brand of brands) {
    console.log(`${brand.name} (${brand.uuid})`);
  }
  ```
</CodeGroup>

### 映射您现有的类别

将您平台的类别转换为我们的类别：

```javascript theme={null}
const categoryMap = {
  "设计师手袋": "bags-category-uuid",
  "运动鞋": "shoes-category-uuid"
};

function getLegitmarkCategory(yourCategory) {
  return categoryMap[yourCategory];
}
```

## 缓存

缓存分类体系数据以提高性能。随着新品牌和类别的添加，分类体系目录会随时间变化，因此定期同步很重要：

```javascript theme={null}
class TaxonomyCache {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.data = null;
    this.lastFetch = null;
  }

  async getTree() {
    const maxAge = 24 * 60 * 60 * 1000; // 24小时
    
    if (this.data && Date.now() - this.lastFetch < maxAge) {
      return this.data;
    }

    const response = await fetch('https://api.legitmark.com/api/v2/categories/tree?active_only=true', {
      headers: { 'Authorization': `Bearer ${this.apiKey}` }
    });
    
    this.data = await response.json();
    this.lastFetch = Date.now();
    
    return this.data;
  }
}
```

每天同步以获取添加到平台的新类别、品牌和型号。

## 后续步骤

1. [设置您的工作流程](/cn/partner/workflow) - 从服务请求创建到图片上传的分步流程
2. [了解状态](/cn/partner/service-request-states) - 服务请求状态和工作流程转换

* [订阅实时事件](/cn/webhook-reference/introduction) - Webhook 通知和状态更新处理

### 快速参考

* [交互式 API 参考](/api-reference) - 使用实时认证和详细规范测试所有端点
