Get category catalog (get_categories)
About 422 words
Returns the full category catalog, used downstream to build category mappings, import goods by category, and display the goods structure in an admin panel.
- Permission:
catalog.read - Method:
GET - Idempotency: read-only
v1 draft
This page is part of the draft v1 integration contract; details may change along with the integration checklist, so rely on the official checklist published in the portal.
点开字段可查看类型与说明
正在加载交互式结构…
Catalog vs. goods list
get_categories returns the category catalog: only the category hierarchy, with no goods details.
get_goods returns the goods list: complete goods → SKU data. Each good carries its category_id, so it maps directly to the categories returned here.
Request example
GET /dist/api/v1/get_categories HTTP/1.1
Host: api.xstock.example
X-Xstock-Api-Key: xs_live_xxxxxxxx
X-Xstock-Timestamp: 1795000000
X-Xstock-Signature: 9f2c1d...No parameters; all categories are returned in one call. Category counts are usually small, so paging is not needed.
Response example
{
"id": "shop-a-20261126-cat-001",
"cmd": "get_categories",
"code": 0,
"msg": "",
"data": {
"default_locale": "zh-CN",
"categories": [
{
"category_id": 1,
"guid": "4f2a9c1d7b3e4a5f8c6d0e1b2a3c4d5e",
"parent_id": 0,
"name": { "zh-CN": "数字账号", "en": "Digital accounts" },
"thumb": "https://cdn.example.com/cat/digital-accounts.png",
"sort_order": 100,
"goods_count": 42
},
{
"category_id": 11,
"guid": "7c3e5a9b1d2f4e6a8b0c3d5e7f9a1b2c",
"parent_id": 1,
"name": { "zh-CN": "流媒体", "en": "Streaming" },
"thumb": "https://cdn.example.com/cat/streaming.png",
"sort_order": 90,
"goods_count": 18
}
]
},
"stamp": 1795000001
}Usage notes
- Categories have at most two levels:
parent_id0marks a top-level category, and a subcategory'sparent_idpoints to its parent. category_idis the numeric identifier, andguidis a 32-character string identifier for the same category (stable across shops and versions, so it suits persistent mappings).nameis a multilingual map,thumbis the category image URL (an empty string when there is no image), anddefault_localeindicates the fallback language.goods_countincludes the goods in subcategories and can drive admin displays and imports by category.- Delisted categories are no longer returned; existing goods mappings do not need to be removed, and the corresponding goods in
get_goodswill showis_active=false. - Corresponds to
GET /categoriesin Dujiao Next; see Integrating with Dujiao Next for the field mapping.
Sync recommendations
| Scenario | Approach |
|---|---|
| First integration | Fetch the catalog first to build category mappings, then fetch the goods list |
| Routine sync | Categories change infrequently; fetching once a day is enough |
| Category markups | Configure markup rules by category_id; the goods list includes this field |
Errors
| code | Scenario | Action |
|---|---|---|
1003 | catalog.read not enabled | Enable the permission in the portal |
4001 | Rate limit triggered | Back off per retry_after |