Bluesky 身份的 PLC 历史
GET/tools/plc-history
来自 PLC 目录的 did:plc 身份操作日志,以时间线呈现:创建、账户代码变更、服务器(PDS)迁移、签名密钥和轮换密钥变更、已作废的操作、墓碑。也接受账户代码。每次返回一页操作,最新的排在最前;可按需提供原始操作。消耗 2 次调用。
参数
| 名称 | 位置 | 类型 | 描述 |
|---|---|---|---|
| q (必填) | query | string | 一个 did:plc、一个账户代码或一个 bsky.app 个人资料链接。 |
| limit | query | integer (1–100), default 50 | 每页的操作数,最新的排在最前:1 到 100,默认为 50。 |
| page | query | integer (1–), default 1 | 操作的页码,从 1 开始。 |
| include_raw | query | boolean, default false | 附上 PLC 目录发布的每个原始操作(`operation`)。 |
响应
| 状态码 | 描述 | 正文 |
|---|---|---|
| 200 | 工具的结果,附带其页面的规范 URL。 | ToolPlcHistory |
| 400 | 查询参数无效(代码 `bad_request`)。 | Error |
| 401 | 令牌未知、已过期或已撤销(代码 `unauthorized`)。不带 `Authorization` 标头时,工具以匿名方式响应。 | Error |
| 404 | 未找到。在机器人的账户代码子域名上也会返回此结果:API 仅在主站点提供。 | Error |
| 429 | 已触发速率限制:每个 IP 受 `toolsApi`(每分钟 60 次)和 `toolsApiDaily`(每天 2,000 次)限制;使用创作者的令牌时,每个账户的两项限制均为其 10 倍。需要发起多次查询的工具,消耗不止一次调用。 | Error |
| 500 | 意外错误。 | Error |
| 502 | 工具请求的服务没有响应(代码 `upstream_error`)。 | Error |
示例
curl \
-G \
--data-urlencode "q=did:plc:z72i7hdynmk6r22z27h6tvur" \
-H "Authorization: Bearer $BLUESKY_BOT_TOKEN" \
https://bluesky.bot/api/v1/tools/plc-history数据结构
Error
| 字段 | 类型 | 描述 |
|---|---|---|
| error (必填) | object | |
| error.code (必填) | string: "bad_request", "invalid_handle", "not_found", "rate_limited", "internal_error", "unauthorized", "forbidden", "conflict", "invalid_grant", "upstream_error", "insufficient_scope", "invalid_listing", "consent_required" | |
| error.message (必填) | string | |
| error.reason | string | 用于 `invalid_handle`、`invalid_listing`、`conflict` 和 `forbidden`:例如 `reserved`、`taken`、`too_long`、`no_handle`、`suspended`。 |
| error.url | string, uri | 用于 consent_required:打开此控制台页面以授权编辑个人资料。 |
| error.field | string | 用于 `invalid_listing`:被拒绝的字段。 |
| error.scope | string | 用于 `insufficient_scope`:令牌缺少的范围。 |
| error.parameter | string | 无效的查询参数。 |
| error.retryAfterSeconds | integer (1–) | 与 `rate_limited` 一起返回。 |
ToolPlcHistory
| 字段 | 类型 | 描述 |
|---|---|---|
| tool (必填) | string = "plc-history" | 工具的 slug。 |
| url (必填) | string | 该工具在 Bluesky.bot 上页面的规范 URL。 |
| result (必填) | object | 工具的结果。 |
| result.did (必填) | string | 这份历史所属的 DID。 |
| result.kind (必填) | string: "history", "too_long", "not_plc" | `history`;日志超过 1 MB 时为 `too_long`;did:web 或其他没有公开日志的方法为 `not_plc`。 |
| result.summary (必填) | object | null | 身份概况;除非 `kind` 为 `history`,否则为 null。 |
| result.truncated (必填) | boolean | 超过 1,000 个操作:只列出最新的 1,000 个。 |
| result.operations (必填) | object[] | 一页操作,最新的排在最前。 |
| result.operations[].cid (必填) | string | 该操作的 CID。 |
| result.operations[].createdAt (必填) | string | PLC 目录收到它的时间。 |
| result.operations[].type (必填) | string: "plc_operation", "create", "plc_tombstone" | `plc_operation`、旧版的 `create`,或 `plc_tombstone`。 |
| result.operations[].nullified (必填) | boolean | 之后(72 小时内)被优先级更高的轮换密钥覆盖;目录仍会保留它。 |
| result.operations[].events (必填) | object[] | 与上一个有效操作相比发生了哪些变化。 |
| result.operations[].events[].kind (必填) | string: "created", "handle", "pds", "signing_key", "rotation_keys", "services", "other", "tombstone", "no_change" | `created`、`handle`、`pds`(迁移到另一台服务器)、`signing_key`、`rotation_keys`、`services`(其他服务)、`other`(其他别名或验证方法)、`tombstone` 或 `no_change`。 |
| result.operations[].events[].from (必填) | string | null | 变更前:账户代码、PDS 端点或签名密钥;不存在或不适用时为 null。 |
| result.operations[].events[].to (必填) | string | null | 变更后:账户代码、PDS 端点或签名密钥;不存在或不适用时为 null。 |
| result.operations[].events[].added (必填) | string[] | 新增的轮换密钥。 |
| result.operations[].events[].removed (必填) | string[] | 移除的轮换密钥。 |
| result.operations[].operation | object | PLC 目录发布的原始操作,仅在使用 `include_raw` 时提供。 |
| result.page (必填) | integer | 返回的操作页码。 |
| result.pages (必填) | integer | 按此 `limit` 计算,操作共有多少页。 |
| result.notes (必填) | object[] | 值得留意的提示:轮换密钥和服务器在 24 小时内都发生变化时为 `keys_and_server`(可能是迁移,也可能是被接管)。 |
| result.notes[].kind (必填) | string: "keys_and_server" | 提示的类型。 |
| result.notes[].at (必填) | string | 服务器变更的时间。 |