通用约定

  • 基地址:https://x2post.com/api/open/v1
  • 鉴权:Authorization: Bearer <access_token>(OAuth 授权拿到)或 <个人令牌>(用户在「资料设置 → 接口令牌」自建)
  • 限流:每个令牌每分钟 60 次,超出 429 + Retry-After: 60
  • 时间格式:ISO-8601(2026-09-22T00:00:00,东八区)

GET /me

需要 scope:profile:read

{
  "id": 1,
  "username": "moatkon",
  "avatarUrl": "https://…/avatar.png",
  "bio": "一句话简介",
  "member": true,
  "level": 12,
  "xp": 3480,
  "profileUrl": "https://x2post.com/users/moatkon",
  "createdAt": "2026-05-01T10:00:00"
}

不会返回邮箱、账号状态、两步验证等站内隐私字段。

GET /me/posts

需要 scope:posts:read

参数:page(默认 0)、size(默认 20,最大 50)

{
  "items": [
    {
      "id": 11,
      "title": "标题",
      "excerpt": "摘要(纯文本,已截断)",
      "url": "https://x2post.com/posts/11",
      "categoryName": "开放讨论",
      "createdAt": "2026-09-21T20:00:00",
      "likeCount": 3,
      "commentCount": 1,
      "viewCount": 42
    }
  ],
  "page": 0,
  "size": 20,
  "totalElements": 9,
  "totalPages": 1
}

GET /(元信息)

返回当前令牌的 scope 与端点清单,用于自检令牌是否有效:

{
  "name": "X2Post 开放接口",
  "version": "v1",
  "scopes": ["profile:read"],
  "endpoints": [{ "method": "GET", "path": "/api/open/v1/me", "scope": "profile:read" }],
  "docs": "https://x2post.com/developers"
}

scope 一览

scope 能读什么 不能读什么
profile:read 昵称、头像、简介、会员状态、等级与经验值 邮箱、账号状态、设备、钱包
posts:read 你发布的帖子列表(标题、摘要、链接、互动数) 他人未公开内容、草稿、私信

状态码

HTTP 含义 处理建议
200 成功 —
401 令牌缺失/无效/过期/已撤销,或账号状态不可用 重新授权或提示用户重新登录
403 令牌缺少该接口所需的 scope 检查授权时申请的 scope
429 触发限流 按 Retry-After 退避