获取站点列表

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

基本信息

接口名称: 获取一个某个用户所拥有的站点列表

接口类型: 数据获取

接口说明: 获取一个某个用户所拥有的站点列表

详细信息

URL

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

完整URL示例

https://www.baklib.com/api/v1/tenants?_page=1&_per_page=2

HTTP请求方式

GET

授权认证方式

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

Authorization: Bearer <token>

请求参数

参数 必选 类型及范围 说明
_page false Integer 需要显示的页码, 默认1
_per_page false Integer 每页显示数量, 默认10, 最大不能超过50

示例代码

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 = {
  _page: 1,
  _per_page: 2
}
response = client.get("/api/v1/tenants", params)
JSON.parse(response.body)

返回结果

{
  "code": 0,
  "status": "success",
  "message": {
    "meta": {
      "current_page": 1,
      "total_pages": 6,
      "total_count": 11
    },
    "items": [
      {
        "id": "b7e02fd6-bc76-478b-9866-9c890691f38c",
        "name": "外星博客",
        "identifier": "bca7c0",
        "domain": null,
        "site_title": null,
        "site_slogan": null,
        "site_logo": null,
        "site_icon": null,
        "site_color": null,
        "created_at": "2020-03-30T10:05:33.244+08:00",
        "updated_at": "2020-03-30T10:05:33.305+08:00",
        "user": {
          "id": "5b062111-13d7-41a2-9d2b-f3e0de23c98c",
          "mobile_phone": "13800000000",
          "name": "hello",
          "image": "https://example.com/1/avatar.png",
          "email": null
        },
        "access_level": 0,
        "site_header_image": null,
        "icp_info": null,
        "plan": 0,
        "plan_expires_at": null,
        "site_header_mask": null,
        "allow_robots": false
      },
      {
        "id": "5e0cbc2a-1bdf-4be2-a6df-c1cf10ee3de6",
        "name": "外星博客",
        "identifier": "5383ba",
        "domain": null,
        "site_title": null,
        "site_slogan": null,
        "site_logo": null,
        "site_icon": null,
        "site_color": "d744ba",
        "created_at": "2020-03-30T10:05:55.184+08:00",
        "updated_at": "2020-03-30T10:05:55.210+08:00",
        "user": {
          "id": "5b062111-13d7-41a2-9d2b-f3e0de23c98c",
          "mobile_phone": "13800000000",
          "name": "hello",
          "image": "https://example.com/avatar.png",
          "email": null
        },
        "access_level": 0,
        "site_header_image": null,
        "icp_info": null,
        "plan": 0,
        "plan_expires_at": null,
        "site_header_mask": null,
        "allow_robots": false
      }
    ]
  }
}

返回字段说明

返回值字段 字段类型 说明
code Integer 状态码
status String 返回状态
current_page Integer 当前页数
total_pages Integer 总页数
total_count Integer 总数量
id String 站点ID
name String 站点名称
identifier String 站点唯一标识符
domain String 二级域名
site_title String 网站名称 (可能是多余字段)
site_slogan String 宣传标语
site_logo String 站点logo
site_icon String 导航栏logo
site_color String 站点主题颜色
created_at Datetime 创建时间
updated_at Datetime 更新时间
user Obj 站点所有者
      id String 用户id
      mobile_phone String 用户手机号
      name String 用户名称
      image String 用户头像
      email String 用户邮箱
access_level Integer 访问类型
site_header_image String 标语图片
icp_info String 备案信息
plan Integer 购买的版本
plan_expires_at Datetime 版本到期时间
site_header_mask String 标语图蒙版颜色
allow_robots boolean 允许搜索引擎收录