PlainMote

HTTP API

脚本携带个人访问令牌调用 /api/v1;令牌通过设备授权获取,与 plainmote login 相同。

获取令牌
  1. 申请验证码。scope 为 read 或 write;device 是确认时以及“已授权应用”中显示的名称。

    $ curl -X POST -H 'Content-Type: application/json' \ -d '{"scope": "read", "device": "my-script"}' https://plainmote.link/api/v1/device/code
  2. 在已登录的浏览器中打开 https://plainmote.link/cli/device,输入响应中的 user_code 并允许。

  3. 每隔 interval 秒用 device_code 轮询。允许之前返回 400 authorization_pending,允许后返回 access_token。

    $ curl -X POST -H 'Content-Type: application/json' \ -d '{"device_code": "…"}' https://plainmote.link/api/v1/device/token
  4. 在 Authorization 请求头中携带令牌。放在地址或 Cookie 中的令牌不会被接受。

    $ curl -H "Authorization: Bearer $PLAINMOTE_TOKEN" https://plainmote.link/api/v1/resources
接口
请求权限用途
POST /api/v1/device/code无需令牌申请验证码
POST /api/v1/device/token无需令牌用验证码换取令牌
GET /api/v1/meread当前账号与令牌
GET /api/v1/keyringread账号的密钥环,用于加密资源
GET /api/v1/resourcesread列出资源,q 按名称筛选,tag 按标签筛选
GET /api/v1/resources/{id}read资源详情
GET /api/v1/resources/{id}/contentread以原始字节读取内容
PUT /api/v1/resources/{id}/contentwrite保存为新版本,If-Match 指明编辑所基于的版本
POST /api/v1/resourceswrite以 multipart 表单的 content 文件创建资源,tag 字段为其打标签
PATCH /api/v1/resources/{id}/tagswrite添加或移除资源的标签
GET /api/v1/tagsread列出账号的所有标签及其资源数
POST /api/v1/quick-shareswrite创建快速分享并返回链接
DELETE /api/v1/tokenread撤销当前令牌
约定
格式JSON;读取和保存内容时为原始字节。时间为 UTC 的 RFC 3339 格式。
错误{"error": "<code>", "message": "…"}
令牌自登录起 90 天有效。只读令牌调用写入接口时返回 403。
频率限制每个令牌每分钟 300 次;超出返回 429 rate_limited。
加密内容以密文返回,由客户端用主密码解密。
不提供删除资源、管理分享链接、查看访问记录。

完整的请求和响应格式见源代码: docs/api.md