API
open-tools API
以程式存取所有工具。可將批次 PDF 或圖片工作接到你自己的流程裡。
快速開始
- 建立帳戶 如果你還沒有的話。
- 從這裡鑄造 API 金鑰: 帳戶 → API 金鑰。完整 token 只會顯示 一次;請現在複製。
- 每次請求都將 token 作為
Authorization: Bearer otk_…傳送。
參考
完整 OpenAPI 規格 — 每個端點、每個參數、每種回應形狀 — 都會從 FastAPI app 自動產生,並以 JSON 提供。Swagger UI 與 ReDoc 都能呈現它。
開啟互動式 API 參考 →偏好原始規格或即時主控台?機器可讀的 OpenAPI JSON 以及 Swagger / ReDoc 探索工具僅提供給已登入帳戶:
範例 — 分割 PDF
上傳檔案並輪詢結果:
# 1. Upload and create the job
curl -X POST 'https://api.open-tools.app/api/upload' \
-H 'Authorization: Bearer otk_YOUR_KEY' \
-F 'file=@input.pdf' \
-F 'job_type=pdf-split' \
-F 'parameters={"pages": "1-3"}'
# → {"job_id": "abc123", "status": "queued", "ws_token": "..."}
# 2. Poll job status (or subscribe via WebSocket /ws/<job_id>?token=<ws_token>)
curl 'https://api.open-tools.app/api/jobs/abc123' \
-H 'Authorization: Bearer otk_YOUR_KEY'
# → {"status": "completed", "output_file_url": "https://api.open-tools.app/api/download/users/42/..."}
# 3. Download the result
curl -o output.pdf 'https://api.open-tools.app/api/download/users/42/<uuid>.pdf' \
-H 'Authorization: Bearer otk_YOUR_KEY'錯誤碼
所有錯誤都共用相同的包裝格式:
{
"detail": {
"error": {
"code": "INVALID_FILE_TYPE",
"message": "image-resize requires PNG, JPG, or WEBP.",
"details": { "expected_extensions": [".png", ".jpg", ".webp"] }
}
}
}| HTTP | 代碼 | 意義 |
|---|---|---|
| 400 | INVALID_FILE_TYPE | 檔案副檔名不在此工作的允許清單中。 |
| 400 | INVALID_FILE_SIGNATURE | Magic bytes 與副檔名不符。 |
| 400 | INVALID_PARAMETERS | 這個 parameters JSON 未通過 schema 驗證。 |
| 401 | AUTH_REQUIRED | 請求中沒有工作階段 cookie 或 API 金鑰。 |
| 403 | REAUTH_REQUIRED | 敏感操作;工作階段已超過 15 分鐘。 |
| 413 | FILE_TOO_LARGE | 上傳超過 50 MB 上限。 |
| 429 | RATE_LIMITED | 超過方案時間窗限制。請見 Retry-After. |
| 500 | INTERNAL_ERROR | Bug。請附上 request_id 標頭。 |
速率限制與用量
每個帳戶都有每分鐘、每小時、每日、每月的額度桶。目前用量可在這裡查看: 你的帳戶儀表板。遇到 429?等時間窗滑過;回應會包含Retry-After 秒。