Toolorah API
通过 HTTPS 以编程方式运行工具:每款工具使用统一的端点,JSON 输入、JSON 输出。适用于 Pro (每天 1,000 次调用)和 Elite(每天 10,000 次调用)。
快速开始
每款工具都使用下方所示端点。将 API 密钥作为 Bearer 令牌发送,并提供包含 input 和 options 的 JSON 请求体。以下是三种语言中的相同调用: POST /api/v1/<tool> { input, options }
curl -X POST https://toolorah.com/api/v1/base64 \
-H "Authorization: Bearer nt_live_xxx" \
-H "Content-Type: application/json" \
-d '{"input":"hello world","options":{"mode":"encode"}}' const res = await fetch("https://toolorah.com/api/v1/base64", {
method: "POST",
headers: {
"Authorization": "Bearer nt_live_xxx",
"Content-Type": "application/json",
},
body: JSON.stringify({ input: "hello world", options: { mode: "encode" } }),
});
const data = await res.json();
console.log(data.result); // "aGVsbG8gd29ybGQ=" import requests
res = requests.post(
"https://toolorah.com/api/v1/base64",
headers={"Authorization": "Bearer nt_live_xxx"},
json={"input": "hello world", "options": {"mode": "encode"}},
)
print(res.json()["result"]) # aGVsbG8gd29ybGQ= 身份验证
在 API 密钥页面创建密钥,然后在每次请求中将其作为 Bearer 令牌发送: 获取 API 密钥
Authorization: Bearer nt_live_xxxxxxxxxxxxxxxx 密钥拥有创建时所属套餐的权限。请像保护密码一样保护密钥:仅保存在服务器端,并在密钥页面撤销任何泄露的密钥。
请求与响应
所有端点均使用 POST,并接受包含两个字段的 JSON 请求体:
input— 要处理的文本(对于 PDF 工具则为 Base64 文件)。options— 每款工具专用的设置对象。此字段可选,并会使用合理的默认值。
调用成功时返回 200 和以下结构:
{
"tool": "base64",
"result": "aGVsbG8gd29ybGQ=",
"meta": { }
} 发生错误时返回非 2xx 状态和单个 error 字段:
{ "error": "Invalid or revoked API key." } 速率限制
- Pro — 每天 1,000 次调用
- Elite — 每天 10,000 次调用
限制在 00:00 UTC 重置。每个响应都会包含当前配额:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 942 超过限制后,调用会返回 429 和 Retry-After 标头。格式错误的请求不会计入配额。
端点
文本与实用工具。使用列出的 options 控制行为。
| 工具 | 端点 | 选项 |
|---|---|---|
base64 | POST /api/v1/base64 | { "mode": "encode" } mode: encode | decode |
url-encoder | POST /api/v1/url-encoder | { "mode": "encode" } mode: encode | decode |
json-formatter | POST /api/v1/json-formatter | { "mode": "format", "indent": 2 } mode: format | minify | validate |
jwt-decoder | POST /api/v1/jwt-decoder | 解码标头和载荷(不验证签名)。 |
hash-generator | POST /api/v1/hash-generator | { "algo": "SHA-256" } algo: SHA-1 | SHA-256 | SHA-512 |
regex-tester | POST /api/v1/regex-tester | { "pattern": "\\d+", "flags": "g", "mode": "match" } mode: match | replace (+ replaceWith) |
word-counter | POST /api/v1/word-counter | 返回单词、字符和句子数量。 |
case-converter | POST /api/v1/case-converter | { "type": "title" } type: upper, lower, title, sentence, camel, pascal, snake, kebab, constant |
text-cleaner | POST /api/v1/text-cleaner | { "trim": true, "collapseSpaces": true } 清理空白和特殊字符。 |
remove-duplicate-lines | POST /api/v1/remove-duplicate-lines | { "caseSensitive": false } 删除重复行。 |
text-sorter | POST /api/v1/text-sorter | { "order": "asc", "numeric": false } 对行进行排序。 |
text-reverser | POST /api/v1/text-reverser | { "mode": "characters" } mode: characters | words | lines |
markdown-formatter | POST /api/v1/markdown-formatter | 将 Markdown 转换为 HTML。 |
lorem-ipsum | POST /api/v1/lorem-ipsum | { "count": 3, "unit": "paragraphs" } unit: paragraphs | sentences | words(无需 input) |
password-generator | POST /api/v1/password-generator | { "length": 16, "symbols": true } 无需 input。 |
random-number | POST /api/v1/random-number | { "min": 1, "max": 100, "count": 5 } 无需 input。 |
percentage-calculator | POST /api/v1/percentage-calculator | { "operation": "percentOf", "a": 20, "b": 150 } operation: percentOf | isWhatPercentOf | percentChange |
uuid-generator | POST /api/v1/uuid-generator | { "count": 5, "upper": false, "noHyphens": false, "braces": false } 生成 v4 UUID(无需 input)。 |
timestamp-converter | POST /api/v1/timestamp-converter | 接受秒或毫秒格式的 Unix 时间戳,并返回 ISO、UTC、本地和 epoch 值。 |
css-minifier | POST /api/v1/css-minifier | 通过删除注释和空白来压缩 CSS。 |
html-formatter | POST /api/v1/html-formatter | { "mode": "beautify", "indent": 2 } mode: beautify | minify (indent: number | "tab") |
markdown-preview | POST /api/v1/markdown-preview | 将 Markdown 转换为 HTML。 |
PDF 端点
PDF 工具处理文件,因此请求会在 JSON 中携带 Base64 编码文件,响应的 result 是 Base64 输出 PDF。每次请求的解码后负载应低于约 4 MB。WebP 仅适用于浏览器;请向 API 发送 PNG 或 JPG。
| 工具 | 端点 | 请求体 |
|---|---|---|
pdf-merger | POST /api/v1/pdf-merger | { "files": ["<base64>", "<base64>", …] } 2–20 个 PDF,按照数组顺序合并。 |
pdf-splitter | POST /api/v1/pdf-splitter | { "file": "<base64>", "options": { "mode": "extract", "pages": "1-3, 5" } } mode: extract | remove。页面范围的用法与网页工具相同。 |
png-to-pdf | POST /api/v1/png-to-pdf | { "images": ["<base64>", …], "options": { "pageSize": "a4", "orientation": "auto", "margin": "small" } } 1–50 张 PNG/JPG 图片,每张一页。pageSize: a4 | letter | fit;margin: none | small | large。 |
# Merge two PDFs (bash)
curl -X POST https://toolorah.com/api/v1/pdf-merger \
-H "Authorization: Bearer nt_live_xxx" \
-H "Content-Type: application/json" \
-d "{\"files\":[\"$(base64 -w0 a.pdf)\",\"$(base64 -w0 b.pdf)\"]}" \
| jq -r '.result' | base64 -d > merged.pdf 错误
401— API 密钥缺失或无效403— 你的套餐不包含 API 访问权限404— 未知工具422— 输入错误(例如无效的 JSON 或正则表达式)429— 已达到每日限制