内容分类操作

获取内容分类详情

接口

GET /hserve/v2.2/content/category/:category_id/

其中 category_id 是内容分类的 ID

请求示例

  1. curl -X GET \
  2. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  3. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  4. -H "Content-Type: application/json" \
  5. https://{{服务器域名}}/hserve/v2.2/content/category/1/

返回示例

  1. {
  2. "children": [
  3. {
  4. "have_children": false,
  5. "id": 1554806396128475,
  6. "name": "test"
  7. }
  8. ],
  9. "have_children": true,
  10. "id": 1554806170889376,
  11. "name": "ifanr"
  12. }

返回参数说明

参数类型说明
idinteger分类 ID
childrenobject array子分类详情
have_childrenbool是否有子分类
namestring分类名称

获取内容分类列表

接口

GET /hserve/v2.2/content/category/

该接口支持通过参数 return_total_count 指定是否返回查询对象总数,以协助不关心对象总数只关心查询结果列表的开发者提升接口响应速度。同时,从 v2.2 版本开始该接口默认不返回查询对象总数,欲获取总数的开发者需要显式指定 return_total_count 参数。

请求参数

  • content_group_id 内容库列表,必选参数。
  • return_total_count 指定是否在返回结果 meta 中返回 total_count

若开发者只需要获取对象总数,则可以通过设置 limit=1 以及 return_total_count=1 来达到该效果,total_count 可从返回的 meta 中获取

请求示例:

  1. https://{{服务器域名}}/hserve/v2.2/content/category/?limit=1&return_total_count=1

请求示例

  1. curl -X GET \
  2. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  3. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  4. -H "Content-Type: application/json" \
  5. https://{{服务器域名}}/hserve/v2.2/content/category/?content_group_id=1

返回参数说明

参数类型说明
idstringid, 唯一标识
namestring分类名称
have_childrenbool是否有子分类
offsetinteger偏移量
limitinteger每次请求返回的最大记录数目
previousstring上一页地址
nextstring下一页地址
total_countinteger记录总数目,仅当 return_total_count 为 1 时返回

返回示例

  1. {
  2. "meta": {
  3. "limit": 20,
  4. "next": null,
  5. "offset": 0,
  6. "previous": null,
  7. "total_count": 3
  8. },
  9. "objects": [
  10. {
  11. "have_children": true,
  12. "id": 1554806170889376,
  13. "name": "ifanr"
  14. },
  15. {
  16. "have_children": false,
  17. "id": 1554806175759642,
  18. "name": "weixin"
  19. },
  20. {
  21. "have_children": false,
  22. "id": 1554806180997534,
  23. "name": "tit"
  24. }
  25. ]
  26. }