Bluesky 帖文字符计数器

GET/tools/character-counter

按照 Bluesky 的方式计算帖文长度(字素,上限 300;UTF-8 字节,上限 3000),过长时将其拆分成多个都不超限的讨论串片段。

参数

名称位置类型描述
text (必填)querystring帖文的文本,最多 10,000 个字符。
numberedqueryboolean, default true在每个讨论串片段末尾加上 ` 1/3`、` 2/3`……

响应

状态码描述正文
200工具的结果,附带其页面的规范 URL。ToolCharacterCounter
400查询参数无效(代码 `bad_request`)。Error
401令牌未知、已过期或已撤销(代码 `unauthorized`)。不带 `Authorization` 标头时,工具以匿名方式响应。Error
404未找到。在机器人的账户代码子域名上也会返回此结果:API 仅在主站点提供。Error
429已触发速率限制:每个 IP 受 `toolsApi`(每分钟 60 次)和 `toolsApiDaily`(每天 2,000 次)限制;使用创作者的令牌时,每个账户的两项限制均为其 10 倍。需要发起多次查询的工具,消耗不止一次调用。Error
500意外错误。Error

示例

bash
curl \
  -G \
  --data-urlencode "text=Hello Bluesky! 👋" \
  -H "Authorization: Bearer $BLUESKY_BOT_TOKEN" \
  https://bluesky.bot/api/v1/tools/character-counter

数据结构

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.reasonstring用于 `invalid_handle`、`invalid_listing`、`conflict` 和 `forbidden`:例如 `reserved`、`taken`、`too_long`、`no_handle`、`suspended`。
error.urlstring, uri用于 consent_required:打开此控制台页面以授权编辑个人资料。
error.fieldstring用于 `invalid_listing`:被拒绝的字段。
error.scopestring用于 `insufficient_scope`:令牌缺少的范围。
error.parameterstring无效的查询参数。
error.retryAfterSecondsinteger (1–)与 `rate_limited` 一起返回。

ToolCharacterCounter

字段类型描述
tool (必填)string = "character-counter"工具的 slug。
url (必填)string该工具在 Bluesky.bot 上页面的规范 URL。
result (必填)object工具的结果。
result.graphemes (必填)integer以字素计的长度:读者眼中的一个字符(一个表情符号、一面旗帜、一个带重音符号的字母)。
result.bytes (必填)integer以 UTF-8 字节计的大小。
result.graphemesLeft (必填)integer距离上限还剩的字素数;超出时为负数。
result.bytesLeft (必填)integer距离上限还剩的字节数;超出时为负数。
result.over (必填)boolean超出任一上限:Bluesky 会拒绝它。
result.limits (必填)object帖文文本的上限。
result.limits.graphemes (必填)integerBluesky 的上限:300。
result.limits.bytes (必填)integerBluesky 的上限:3000。
result.parts (必填)object[]文本超出上限时的讨论串:在段落、句子或空格处切分的片段。不超限时为空。
result.parts[].text (必填)string片段的文本,按要求编号。
result.parts[].graphemes (必填)integer片段以字素计的长度。
result.parts[].bytes (必填)integer片段以 UTF-8 字节计的大小。
result.parts[].over (必填)boolean该片段仍然过长:单个字素就超过了一条帖文的上限。