跳转到主要内容

概述

Legitmark 使用四级层次分类系统。每个级别决定认证要求和服务选择: 层次级别:
  • 第 1 级:类别(必需)- 广泛的产品分类
  • 第 2 级:类型(必需)- 具体的产品子类别
  • 第 3 级:品牌(可选)- 制造商或设计师
  • 第 4 级:型号(可选)- 具体的产品变体

获取分类体系数据

完整树

一次请求获取所有内容用于初始设置: API 参考: 获取分类体系树 - GET /api/v2/categories/tree
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();
分类体系树包括类别和类型(必需),以及品牌和型号(可选)。强烈建议匹配品牌和型号以根据完整的分类体系深度获得更具体的图片要求。如果未匹配品牌和型号,可能需要额外的照片进行认证。

关键筛选端点

其他端点

集成方法

直接使用我们的分类体系

向您的用户展示 Legitmark 类别:
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); // "箱包", "鞋类" 等
});

获取选定类型的品牌

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

映射您现有的类别

将您平台的类别转换为我们的类别:
const categoryMap = {
  "设计师手袋": "bags-category-uuid",
  "运动鞋": "shoes-category-uuid"
};

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

缓存

缓存分类体系数据以提高性能。随着新品牌和类别的添加,分类体系目录会随时间变化,因此定期同步很重要:
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. 设置您的工作流程 - 从服务请求创建到图片上传的分步流程
  2. 了解状态 - 服务请求状态和工作流程转换

快速参考