获取文章详细

基本信息

接口名称: 获取文章详细信息

接口类型: 数据获取

接口说明: 获取某篇文章的详细信息

详细信息

URL

https://www.baklib.com/api/v1/articles/:id

完整URL示例

https://www.baklib.com/api/v1/articles/8872dace-2aea-45aa-9517-a14ca9098bbd?tenant_id=aaa24dbe-a17b-4439-911d-176e0149cf76

HTTP请求方式

GET

授权认证方式

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

Authorization: Bearer <token>

请求参数

参数 必选 类型及范围 说明
tenant_id true String 站点id
id true String 文章id

示例代码


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/8872dace-2aea-45aa-9517-a14ca9098bbd?tenant_id=aaa24dbe-a17b-4439-911d-176e0149cf76");
xhr.setRequestHeader("Authorization", "Bearer 8486df9cb8a93ea843702141065c4a8b714602b45e7c4a6bb26a26ea3d69de6");


xhr.send();

返回结果

{
    "code": 0,
    "status": "success",
    "message": {
        "id": "8872dace-2aea-45aa-9517-a14ca9098bbd",
        "parent_id": "ec9fc220-72b8-4e3e-b6d3-4b472fb38c46",
        "name": "传入content_type为raw",
        "identifier": "207c",
        "description": "这是描述",
        "content": {
            "time": 1668669785851,
            "blocks": [
                {
                    "id": "guNSvTDzsg",
                    "data": {
                        "text": "Hello, Baklib!",
                        "alignment": "align-left"
                    },
                    "type": "paragraph"
                },
                {
                    "id": "tRi5OCbGaX",
                    "data": {
                        "url": "http://dev.bk-cdn.com/t/aaa24dbe-a17b-4439-911d-176e0149cf76/u/822ca2a8-b3b7-4d7c-aaed-8cd3b221373f/1668668621876/v2-454fba3b1159d364b448f77e092aef74.jpg",
                        "caption": "说明",
                        "stretched": false,
                        "withBorder": false,
                        "isHistoryImage": false,
                        "withBackground": false
                    },
                    "type": "qiniuImage"
                },
                {
                    "id": "f_J2OncGRk",
                    "data": {
                        "text": "",
                        "alignment": "align-left"
                    },
                    "type": "paragraph"
                }
            ],
            "version": "2.22.2"
        },
        "ordinal": 0,
        "status": 0,
        "status_name": "草稿",
        "kind": 2,
        "kind_name": "文章",
        "slug": "unclassified/207c",
        "tenant_id": "aaa24dbe-a17b-4439-911d-176e0149cf76",
        "visits_count": 0,
        "fake_visits_count": 800,
        "created_at": "2022-11-09T10:57:20.634+08:00",
        "updated_at": "2022-11-17T18:09:34.680+08:00",
        "created_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
        "updated_by": "822ca2a8-b3b7-4d7c-aaed-8cd3b221373f",
        "password": "123",
        "access_level": 0,
        "template": "article.default",
        "variables": {},
        "variables_description": [],
        "tag_list": [
            "Ruby",
            "rails"
        ],
        "frontend_url": "XXX",
        "edit_url": "XXX"
    }
}

返回字段说明

返回值字段 字段类型 说明
code Integer 状态码
status String 返回状态
message Hash 返回数据主体
    id String 文章id
    parent_id String 栏目id
    name String 文章标题
    identifier String 栏目唯一标识符
    description String 文章描述
    content Jsonb 文章内容 点击获取文章 content 字段详情
        time Integer 文章创建时间码
        verison String 编辑器相关版本
        blocks Array[String] 对应编辑器中显示的区块
            type String 内容格式类型(paragraph=>段落,quote=>引用,qiniuImage=>图片)
            id String 区块id
            data Jsonb 区块数据
                text String 文本
                alignment String 对齐方式
                url String 图片地址(传图片时)
                caption String 图片说明(传图片时)
                withBorder Boolean 是否加边框(传图片时)
                withBackground Boolean 是否为背景(传图片时)
                stretched Boolean 是否拉伸(传图片时)
                isHistoryImage Boolean 是否为历史图片(传图片时)
    ordinal String 文章排序
    status Integer 文章状态, 0=> '草稿',1=>'已发布';默认为草稿状态。
    status_name String 栏目状态中文名称
    kind Integer 文章类型标志
    kind_name String 文章类型名称
    slug String 文章路径
    tenant_id String 站点id
    visit_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 其他变量
    variables_description Array 变量描述
    tag_list Array 标签结果集
    frontend_url String 前端访问地址
    edit_url String 编辑地址
2022-11-21
0 0