API 文档
JSON API 文档:2FA 验证码、IP、DNS 与 WHOIS 查询以及数据转换的接口。包含 Bearer 密钥认证、速率限制,每个接口都配有 curl 示例。
认证
在 账户 → API 密钥 创建一个密钥,然后作为 bearer token 发送。快速测试时也可以用 X-API-Key 和 ?api_key=。
curl -s https://authbeta.com/api/v1/status \ -H "Authorization: Bearer ab_xxxxxxxxxxxxxxxxxxxx"
基础地址:https://authbeta.com/api/v1 · 所有响应都是 JSON,带一个 ok 标志。
速率限制
每个密钥都有自己的每分钟额度(默认 120)。响应中带有 X-RateLimit-Limit、X-RateLimit-Remaining 和 X-RateLimit-Reset;超出额度会返回 429 并附带 Retry-After 头。
错误
| 状态码 | 含义 |
|---|---|
| 400 | 缺少必填字段。 |
| 401 | 密钥缺失、无效、已停用或已过期。 |
| 403 | 密钥没有该接口所需的权限范围。 |
| 404 | 接口不存在,或保险库里没有该条目。 |
| 422 | 输入能读懂,但无法使用。 |
| 429 | 超出调用频率限制。 |
| 503 | 管理员已关闭 API。 |
{"ok": false, "error": "The \"secret\" field must be a valid base32 string."}
接口
/totp
scope: totp
从密钥、otpauth 链接或任意文本生成验证码。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| secret | uri | input | string | 是 | base32 密钥、otpauth:// 链接,或含有该链接的文本。 |
| digits | int | 否 | 4-10,默认 6 |
| period | int | 否 | 秒数,默认 30 |
| algorithm | string | 否 | SHA1 | SHA256 | SHA512 | STEAM |
| counter | int | 否 | 存在即表示 HOTP 模式 |
| timestamp | int | 否 | 按哪个 Unix 时间计算验证码 |
| include_secret | bool | 否 | 同时返回密钥,默认 false |
/totp/verify
scope: totp
检查验证码与密钥是否匹配。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| secret | string | 是 | base32 密钥 |
| code | string | 是 | 要验证的验证码 |
| window | int | 否 | 允许的步长偏移,0-10,默认 1 |
/totp/secret
scope: totp
生成新的随机密钥及其 otpauth 链接。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| bytes | int | 否 | 10-64,默认 20(160 位) |
| label | string | 否 | 账户名称 |
| issuer | string | 否 | 服务名称 |
/totp/qr
scope: totp
把二维码渲染成 PNG 或 SVG。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| text | secret | string | 是 | 任意文本,或用来生成 otpauth 链接的密钥 |
| format | string | 否 | png(默认)或 svg |
| scale | int | 否 | 2-20,每个模块占多少像素 |
| ecc | string | 否 | L | M | Q | H |
| raw | bool | 否 | 直接返回图片本身,而不是 JSON |
/totp/decode
scope: totp
读取二维码图片并返回其中的 2FA 数据。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| image | string | 是 | base64 图片数据,带不带 data: 前缀都可以 |
/totp/bulk
scope: totp
一次为整份列表生成验证码。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| text | string | 是 | 每行一条 |
| delimiter | string | 否 | auto(默认)、pipe、comma、tab 等 |
| include_secret | bool | 否 | 同时返回密钥,默认 false |
/password
scope: password
生成一个或多个密码。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mode | string | 否 | random | memorable | pin | hex | base64 | uuid |
| length | int | 否 | 4-256 |
| quantity | int | 否 | 1-50 |
| lowercase, uppercase, digits, symbols | bool | 否 | random 模式使用的字符集 |
| exclude_ambiguous, no_repeat, no_sequential | bool | 否 | 额外规则 |
| words | int | 否 | memorable 模式用,2-12 |
/password/strength
scope: password
给密码打分。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| password | string | 是 | 要分析的密码 |
/ip/{ip}
scope: ip
IP 地址的详细信息。不填 {ip} 就用你自己的地址。
/dns
scope: ip
某个主机名的 DNS 记录。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| host | string | 是 | 域名 |
| type | string | 否 | 用逗号分隔的列表,默认 A,AAAA,MX,NS,TXT |
/whois
scope: ip
某个域名或 IP 的 WHOIS 数据。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| query | string | 是 | 域名或 IP |
/ports
scope: ip
检查 TCP 或 UDP 端口是否接受流量。TCP 返回 open/closed/filtered。UDP 返回 open、closed(ICMP 不可达)、likely_open(无回应但目标主机会报告关闭的端口)或 open|filtered,并附带 icmp 字段说明目标主机是否报告关闭的端口。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| host | string | 是 | 主机名或 IP 地址 |
| protocol | string | 否 | tcp(默认)或 udp |
| ports | array|string | 否 | 端口列表,或者 "53,123,161"。不填就用所选协议的常用端口。 |
/email-security
scope: ip
某个域名的 SPF、DMARC、MX、MTA-STS 和 TLS-RPT。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| domain | string | 是 | 域名 |
/text
scope: text
执行一项文本处理操作。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| text | string | 是 | 输入文本 |
| operation | string | 是 | 见下方的操作列表 |
| … | mixed | 否 | 各操作自己的参数(delimiter、column、find、replace 等) |
/vault
scope: vault
列出你保存的 2FA 账户及当前验证码。
/vault/{id}/code
scope: vault
保险库中某一条目的当前验证码。HOTP 条目会推进计数器。
/status
关于你正在使用的这个密钥的信息。
示例
curl -s https://authbeta.com/api/v1/totp \
-H "Authorization: Bearer ab_xxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"secret":"JBSWY3DPEHPK3PXP","digits":6}'
{
"ok": true,
"result": {
"issuer": "", "label": "", "digits": 6, "period": 30,
"algorithm": "SHA1", "type": "totp",
"code": "123456", "next_code": "654321",
"expires_in": 17, "server_time": 1771200000
}
}
文本处理操作
POST /text 的 operation 字段可接受的值:
trim_lines
remove_empty
remove_duplicates
sort_asc
sort_desc
sort_natural
sort_length
shuffle
reverse_lines
reverse_text
number_lines
unique_count
extract_column
replace_delimiter
add_prefix_suffix
wrap_lines
find_replace
regex_replace
upper
lower
title
sentence
camel
snake
kebab
toggle_case
remove_spaces
collapse_spaces
remove_accents
slugify
base64_encode
base64_decode
url_encode
url_decode
html_encode
html_decode
hex_encode
hex_decode
json_escape
json_pretty
json_minify
extract_emails
extract_urls
extract_ips
extract_numbers
extract_secrets
hash_md5
hash_sha1
hash_sha256
hash_sha512
hash_crc32
join_lines
split_length
count_stats