获取栏目列表

基本信息

接口名称: 获取栏目列表

接口类型: 数据获取

接口说明: 获取某个站点的栏目列表

详细信息

URL

https://www.baklib.com/api/v1/channels

完整URL示例

https://www.baklib.com/api/v1/channels?tenant_id=aaa24dbe-a17b-4439-911d-176e0149cf76&_page=1&_per_page=10

HTTP请求方式

GET

授权认证方式

默认方式,需要添加请求header

Authorization: Bearer <token>

请求参数

参数 必选 类型及范围 说明
tenant_id true String 站点id
parent_id false String 父级栏目id
all false Boolean 全部栏目是否分页? 0=>不分页,1=>分页
status false Integer 状态 0=>草稿,1=>已发布
name false String 通过名称来搜索
identifier false String 通过identifier搜索
_page false Integer 需要显示的页码, 默认1
_per_page false Integer 每页显示数量, 默认10, 最大不能超过50

示例代码



var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://www.baklib.com/api/v1/channels?tenant_id=aaa24dbe-a17b-4439-911d-176e0149cf76&status=1&_page=1&_per_page=10");
xhr.setRequestHeader("Authorization", "Bearer 8486df9cb8a93ea843702141065c4a8b714602b45e7c4a6bb26a26ea3d69de6");


xhr.send();

返回结果

{
    "code": 0,
    "status": "success",
    "message": {
        "meta": {
            "current_page": 1,
            "total_pages": 1,
            "total_count": 8
        },
        "items": [
            {
                "id": "9c54ffdc-0d00-4acd-ae9d-c404be15d312",
                "parent_id": "38a4383f-9249-44b7-8531-6c9c35529aac",
                "name": "'测试1108'",
                "identifier": "560d",
                "description": null,
                "ordinal": 0,
                "status": 0,
                "status_name": "草稿",
                "kind": 1,
                "kind_name": "栏目",
                "slug": "560d",
                "tenant_id": "aaa24dbe-a17b-4439-911d-176e0149cf76",
                "visits_count": 0,
                "created_at": "2022-11-09T12:15:26.863+08:00",
                "updated_at": "2022-11-09T12:15:26.841+08:00",
                "created_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
                "updated_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
                "password": null,
                "access_level": 0,
                "variables": {},
                "frontend_url": "XXX",
                "ordinal_type": 0,
                "icon_name": null,
                "channel_template": "channel.default",
                "article_template": "article.default",
                "edit_url": "XXX"
            },
           
        ]
    }
}

返回字段说明

返回值字段 字段类型 说明
code Integer 状态码
status String 返回状态
message Hash 返回数据
    meta Jsonb 元数据
        current_page Integer 当前页数
        total_pages Integer 总页数
        total_count Integer 总数量
    items Array[String] 详情数据项
        id String 栏目id
        parent_id String 父级栏目id
        name String 栏目名称
        identifier String 栏目唯一标识符
        description String 描述
        ordinal Integer 次序
        status Integer 栏目状态
        status_name String 栏目状态中文名称
        kind Integer 栏目种类
        kind_name String 栏目种类中文名称
        slug String 路径
        tenant_id String 站点id
        created_at Datetime 创建时间
        updated_at Datetime 更新时间
        created_by String 创建者id
        updated_by String 更新者id
        password String 密码
        access_level Integer 访问等级
        variables Jsonb 其他变量
        frontend_url String 前端访问地址
        ordinal_type String 排序种类
        icon_name String 图标
        channel_template String 栏目模板
        article_template String 文章模板
        edit_url String 编辑地址
2022-11-18
0 0