簡介
提供用於文件翻譯的RESTful API,支援自動化翻譯任務管理、基於術語表的術語一致性,以及對支援格式、語言和模型的查詢,便於建構無縫翻譯工作流程和管理使用者帳戶。
入門指南
要開始使用,您需要申請成為開發者。申請成為開發者
一旦獲得覈准,您可以建立多個API金鑰,並根據需要在每個API請求中包含相應的API金鑰。
快速接入
Base URL
https://otranslator.com/api
認證方式
Authorization: [yourSecretKey]
JSON 請求
除文件上傳接口外,接口默認使用 POST JSON 請求,Content-Type 為 application/json。
檔案上傳
建立文件翻譯任務使用 multipart/form-data,file 欄位傳入待翻譯檔案。
通用錯誤響應
請求失敗時介面會返回 JSON,error 欄位包含固定英文錯誤訊息。建議優先按 HTTP status code 分支處理錯誤,error 欄位用於展示或日誌記錄。
{
"error": "Invalid API key."
}錯誤狀態碼規則
所有 v1 API 錯誤響應保持相同結構,請按下列 HTTP status code 規則處理。
- 400 Bad Request
- Missing required parameters, invalid parameter formats or enum values, missing file upload, upload save failure, or task processing failure.
- 401 Unauthorized
- Missing API key or invalid API key.
- 402 Payment Required
- Insufficient credits balance for preview, full translation, or text translation.
- 404 Not Found
- The task or glossary does not exist, has been deleted, does not belong to the current API account, or was not created through the API.
- 409 Conflict
- The current task status does not allow the requested operation.
- 500 Internal Server Error
- Unexpected server exception. The response error is fixed as "Internal server error.".
推薦接入流程
1. 建立任務
上傳檔案並建立翻譯任務,返回 taskId。
2. 查詢進度
輪詢任務狀態,直到 Completed、Terminated 或 Cancelled。
3. 獲取結果
下載譯文檔案,或讀取原文和譯文 JSON。
4. 管理任務
按需支付全文翻譯、重啟任務、修訂文本或刪除任務。