web3baseweb3base

返回全局分类注册表(支持 scope 与 includeI18n),可与 category-groups 联用构建多语言筛选。

获取分类列表

GET /api/open/categories

该接口返回 全局分类注册表 中的分类项:

  • 可按 scope 过滤到 chain / twitter / youtube / item
  • 通过 includeI18n=1 获取 完整多语言标签 + 描述
  • GET /api/open/category-groups 通过 groupKey / moduleGroupKeys 关联

请求地址

GET /api/open/categories

请求参数

参数类型是否必传说明
localestring未传 includeI18n 时,用于解析 name 字段(单语言场景)
scopestring业务域:chain / twitter / youtube / item;省略表示返回全部域
includeI18nstring"1""true" 时,返回完整 i18n 与可选 descriptionI18n

返回体(未传 includeI18n)

200 OKapplication/jsonCategoryItem 结构:

字段类型说明
keystring分类 key,作为对外稳定标识
namestringlocale 解析的展示名
parentstring | null父分类 key(如有)
prioritynumber排序权重
scopesstring[]该分类适用的业务域列表(无 scope 过滤时返回)

返回体(includeI18n=1)

200 OKapplication/jsonCategoryItemFull 结构:

字段类型说明
keystring分类 key
i18nobject各语言名称映射
descriptionI18nobject | undefined各语言描述
parentstring | null父分类
prioritynumber排序
scopesstring[]适用业务域
moduleGroupKeysobject | undefinedscope 为空时,各模块对应的维度组 key 列表
groupKeystring | undefinedscope 不为空时,该分类所属维度组 key

当携带 scope(例如 scope=chain)时,响应项会带上 groupKey,与 category-groups 里的 groups[].key 对齐;不带 scope 时则是 moduleGroupKeys

错误码

HTTP 状态场景
400scope 非法
429命中 open API 限流
500服务器内部错误

请求示例

# 单语言:只关心当前 locale 的 name
curl -s "https://www.web3base.ai/api/open/categories?locale=zh-hans&scope=chain" | jq '.categories[0]'

# 多语言建站:一次拉全语言标签 + 维度分组
curl -s "https://www.web3base.ai/api/open/categories?scope=twitter&includeI18n=1" | jq '.categories[0]'

返回示例(includeI18n=1)

{
  "categories": [
    {
      "key": "l2",
      "i18n": {
        "en": "Layer 2",
        "zh-hans": "二层网络"
      },
      "descriptionI18n": {
        "en": "Layer 2 rollups and sidechains"
      },
      "parent": null,
      "priority": 10,
      "scopes": ["chain"],
      "moduleGroupKeys": {
        "chain": ["ecosystem", "layer"]
      },
      "groupKey": "ecosystem"
    }
  ]
}

← 返回 API 总览