Bluesky 账户代码查找工具(DID 转账户代码)
GET/tools/handle-finder
查找某个 DID 的账户代码:其 DID 文档声明的账户代码、该账户代码是否反向解析到它,以及 AppView 提供的名称和头像。
参数
| 名称 | 位置 | 类型 | 描述 |
|---|---|---|---|
| did (必填) | query | string | 一个 DID(`did:plc:…`、`did:web:example.com`)、一个 `at://did…` URI,或一个包含 DID 的 bsky.app 链接。 |
响应
| 状态码 | 描述 | 正文 |
|---|---|---|
| 200 | 工具的结果,附带其页面的规范 URL。 | ToolHandleFinder |
| 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 "did=did:plc:z72i7hdynmk6r22z27h6tvur" \
-H "Authorization: Bearer $BLUESKY_BOT_TOKEN" \
https://bluesky.bot/api/v1/tools/handle-finder数据结构
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` 一起返回。 |
ToolHandleFinder
| 字段 | 类型 | 描述 |
|---|---|---|
| tool (必填) | string = "handle-finder" | 工具的 slug。 |
| url (必填) | string | 该工具在 Bluesky.bot 上页面的规范 URL。 |
| result (必填) | object | 工具的结果。 |
| result.did (必填) | string | DID。 |
| result.didMethod (必填) | string: "plc", "web" | DID 方法。 |
| result.handle (必填) | string | null | DID 文档声明的账户代码;未声明时为 null。 |
| result.unicodeHandle (必填) | string | null | 国际化账户代码的 Unicode 形式,否则为 null。 |
| result.verified (必填) | boolean | null | 该账户代码反向解析到这个 DID;无法检查时为 null。 |
| result.resolvesTo (必填) | string | null | 该账户代码当前解析到的 DID(当它是另一个 DID 时)。 |
| result.displayName (必填) | string | null | 名称(当 AppView 提供时)。 |
| result.avatar (必填) | string | null | 头像的 URL(当 AppView 提供时)。 |
| result.accountStatus (必填) | string: "takendown", "suspended", "deleted", "deactivated", "desynchronized", "throttled" | null | 账户消失的原因(`takendown`、`suspended`、`deactivated`、`deleted`……);账户仍在时为 null。 |
| result.warnings (必填) | string: "not_bidirectional", "dns_https_conflict", "handle_moved", "multiple_txt", "handle_invalid", "account_gone", "appview_only"[] | 发现的问题,在工具页面上有说明:`not_bidirectional`、`dns_https_conflict`、`handle_moved`、`multiple_txt`、`handle_invalid`、`account_gone`、`appview_only`。 |