基本信息
接口名称: 获取栏目下的文章列表
接口类型: 数据获取
接口说明: 获取一个某个栏目下的文章列表
详细信息
URL
https://www.baklib.com/api/v1/articles
完整URL示例
https://www.baklib.com/api/v1/articles?tenant_id=aaa24dbe-a17b-4439-911d-176e0149cf76&_page=1&_per_page=10
HTTP请求方式
GET
授权认证方式
默认方式,需要添加请求header
Authorization: Bearer <token>
请求参数
| 参数 | 必选 | 类型及范围 | 说明 |
|---|---|---|---|
| tenant_id | true | String | 站点id |
| channel_id | false | String | 栏目id |
| name | false | String | 通过标题搜索 |
| identifier | false | String | 通过identifier搜索 |
| status | false | Integer | 发布状态(0: 草稿, 1: 发布) |
| tag_list | false | Array[string] | 标签 |
| _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/articles?tenant_id=aaa24dbe-a17b-4439-911d-176e0149cf76&_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": 1
},
"items": [
{
"id": "e0a4f846-f090-4901-aff3-66362ab51ffd",
"parent_id": "1dfbdd9d-5b9d-4961-8fae-eed05f6563ce",
"name": "测试1053",
"identifier": "6cba",
"description": "",
"ordinal": 0,
"status": 1,
"status_name": "发布",
"kind": 2,
"kind_name": "文章",
"slug": "xiaohui4/6cba",
"tenant_id": "aaa24dbe-a17b-4439-911d-176e0149cf76",
"visits_count": 0,
"fake_visits_count": 10,
"created_at": "2022-11-09T10:54:45.739+08:00",
"updated_at": "2022-11-14T16:07:59.808+08:00",
"created_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
"updated_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
"password": "123",
"access_level": 1,
"template": "article.default",
"variables": {},
"tag_list": [],
"frontend_url": "XXX",
"edit_url": "XXX"
}
]
}
}
返回字段说明
| 返回值字段 | 字段类型 | 说明 |
|---|---|---|
| code | Integer | 状态码 |
| status | String | 返回状态 |
| message | Hash | 返回数据 |
| meta | Hash | 列表元数据 |
| current_page | Integer | 当前页数 |
| total_pages | Integer | 总页数 |
| total_count | Integer | 总数量 |
| items | Array | 结果集 |
| id | String | 文章id |
| parent_id | String | 栏目id |
| name | String | 文章名称 |
| identifier | String | 唯一标识符 |
| description | String | 文章描述 |
| ordinal | Integer | 文章次序 |
| status | Integer | 文章状态,0=>'草稿',1=>'已发布' |
| status_name | String | 状态含义 |
| kind | Integer | 文章类型 |
| kind_name | String | 文章类型名称 |
| slug | String | 文章路径 |
| tenant_id | String | 站点id |
| visits_count | Integer | 访问总数 |
| fake_visits_count | Integer | 虚拟访问量 |
| created_at | Datetime | 创建时间 |
| updated_at | Datetime | 更新时间 |
| created_by | String | 创建者id |
| updated_by | String | 更新者id |
| password | String | 密码 |
| access_level | Integer | 访问等级 |
| template | String | 文章模板 |
| variables | Jsonb | 其他变量 |
| tag_list | Array[String] | 标签结果集 |
| frontend_url | String | 前端访问地址 |
| edit_url | String | 编辑地址 |