返回全局分类注册表(支持 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
请求参数
| 参数 | 类型 | 是否必传 | 说明 |
|---|---|---|---|
locale | string | 否 | 当 未传 includeI18n 时,用于解析 name 字段(单语言场景) |
scope | string | 否 | 业务域:chain / twitter / youtube / item;省略表示返回全部域 |
includeI18n | string | 否 | 传 "1" 或 "true" 时,返回完整 i18n 与可选 descriptionI18n |
返回体(未传 includeI18n)
200 OK,application/json,CategoryItem 结构:
| 字段 | 类型 | 说明 |
|---|---|---|
key | string | 分类 key,作为对外稳定标识 |
name | string | 按 locale 解析的展示名 |
parent | string | null | 父分类 key(如有) |
priority | number | 排序权重 |
scopes | string[] | 该分类适用的业务域列表(无 scope 过滤时返回) |
返回体(includeI18n=1)
200 OK,application/json,CategoryItemFull 结构:
| 字段 | 类型 | 说明 |
|---|---|---|
key | string | 分类 key |
i18n | object | 各语言名称映射 |
descriptionI18n | object | undefined | 各语言描述 |
parent | string | null | 父分类 |
priority | number | 排序 |
scopes | string[] | 适用业务域 |
moduleGroupKeys | object | undefined | scope 为空时,各模块对应的维度组 key 列表 |
groupKey | string | undefined | scope 不为空时,该分类所属维度组 key |
当携带
scope(例如scope=chain)时,响应项会带上groupKey,与category-groups里的groups[].key对齐;不带scope时则是moduleGroupKeys。
错误码
| HTTP 状态 | 场景 |
|---|---|
400 | scope 非法 |
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"
}
]
}