翻譯任務 API
獲取譯文
POST/v1/translation/queryTexts
獲取系統提取的一一對應的原文和譯文,以 JSON 的格式返回
- 完整地址
- https://otranslator.com/api/v1/translation/queryTexts
- 認證
- 需要在 Authorization 請求頭中傳入 API Key
- Content-Type
- application/json
- 錯誤格式
- { "error": "Invalid API key." }
注意事項
該接口返回翻譯緩存中的結構化文本,適合做譯文修訂、二次處理或同步到業務系統。
如果任務尚未生成文本緩存,texts 和 revisedTexts 會返回空對象。
範例
curl
1curl -X POST 'https://otranslator.com/api/v1/translation/queryTexts' \
2--header 'Authorization: [yourSecretKey]' \
3--header 'Content-Type: application/json' \
4--data '{
5 "taskId": "[string]"
6}'請求參數
| 參數 | 類型 | 預設 | 描述 | 範例 |
|---|---|---|---|---|
| *taskId | String | - | 翻譯任務ID | - |
響應
| 參數 | 類型 | 預設 | 描述 | 範例 |
|---|---|---|---|---|
| taskId | String | - | 翻譯任務ID | - |
| texts | JSON | - | 原文和譯文對應的JSON | - |
| revisedTexts | JSON | - | 已修訂的原文和譯文 | - |
常見錯誤
401 Missing API key.
The Authorization request header is required.
401 Invalid API key.
The API key does not exist, has been deleted, or is no longer valid.
400 Missing required parameter: taskId.
Provide the taskId returned by the create translation task API.
404 Task not found.
The task does not exist, has been deleted, does not belong to the current API account, or was not created through the API.