获取文章详细

Baklib
辉哥2 最后一次编辑 接近 2 年前
709

基本信息

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

接口类型: 数据获取

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

详细信息

URL

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

完整URL示例

https://www.baklib.com/api/v1/articles/24fc71a6-a939-45a8-9fa3-65e57e3d10d0?tenant_id=682c1cf8-41bf-4417-aa05-3e682fb5174b

HTTP请求方式

GET

授权认证方式

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

Authorization: Bearer <token>

请求参数

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

示例代码

require 'faraday'
require 'json'
host = 'https://www.baklib.com'

client = Faraday.new(url: host) do |conn|
  conn.headers['Authorization'] = "Bearer #{token}"
  conn.headers['Content-Type'] = 'application/json'
  conn.adapter :net_http
end
params = {
  tenant_id: "#{tenant_id}",
}
response = client.get("/api/v1/articles/#{article_id}", params)
JSON.parse(response.body)

返回结果

{
  "code": 0,
  "status": "success",
  "message": {
    "id": "0a8e19b9-3391-47b9-a74e-3a0ff23d5114",
    "parent_id": "941ec4db-bfae-46c0-8eb3-89f647aba40d",
    "name": "rails guide",
    "identifier": "0467",
    "description": "本文介绍如何开始使用 Ruby on Rails。",
    "content": {},
    "ordinal": 0,
    "features": {},
    "status": 0,
    "status_name": "草稿",
    "kind": 2,
    "kind_name": "文章",
    "slug": "dcc7/0467",
    "tenant_id": "682c1cf8-41bf-4417-aa05-3e682fb5174b",
    "visits_count": 0,
    "created_at": "2020-04-01T14:39:02.423+08:00",
    "updated_at": "2020-04-01T15:16:37.077+08:00",
    "created_by": "5b062111-13d7-41a2-9d2b-f3e0de23c98c",
    "updated_by": "5b062111-13d7-41a2-9d2b-f3e0de23c98c",
    "tag_list": [
      "doc",
      "rails"
    ],
    "frontend_url": "http://help.xxx.com/ping/dcc7/0467",
    "edit_url": "https://console.baklib.com/~xxx/articles/0a8e19b9-3391-47b9-a74e-3a0ff23d5114",
  }
}

返回字段说明

返回值字段 字段类型 说明
code Integer 状态码
status String 返回状态
message Hash 数据
    id String 文章编号
    parent_id String 栏目编号
    name String 文章标题
    identifier String 文章唯一标识
    description String 文章描述
    content Hash 文章正文内容
    ordinal Integer 文章排序
    status Integer 文章状态
    status_name String 文章状态
    kind Integer 文章类型
    kind_name String 文章类型
    slug String 文章路径
    tenant_id String 站点编号
    visits_count Integer 访问量
    created_at DateTime 创建时间
    updated_at DateTime 更新时间
    created_by String 创建者编号
    updated_by String 更新者编号
    tag_list Array[String] 标签
    frontend_url String 前端访问地址
    edit_url String 后端编辑地址