通用翻譯介面調用說明。
注意事項
1、QPS限制50,如有擴充需求,請與我們聯絡。DingTalk群號:23369411
2、請確保在使用該介面前,已充分瞭解通用版翻譯產品的收費方式和價格
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
請求參數
名稱 | 類型 | 是否必選 | 樣本值 | 描述 |
Action | String | 是 | TranslateGeneral | 系統規定參數。取值:TranslateGeneral。 |
FormatType | String | 是 | text | 翻譯文本的格式,html( 網頁格式。設定此參數將對待翻譯文本以及翻譯後文本按照html格式進行處理)、text(文字格式設定。設定此參數將對傳入待翻譯文本以及翻譯後結果不做文字格式設定處理,統一按純文字格式處理。 |
Scene | String | 是 | general | 通用版本預設是:general |
SourceLanguage | String | 是 | zh | 原文語言參考語言code |
SourceText | String | 是 | 你好 | 需要翻譯的內容 |
TargetLanguage | String | 是 | en | 譯文語言參考語言code |
Context | String | 否 | 早上我在家裡吃了麵包 | 上下文資訊,可選填 |
返回資料
樣本
請求樣本
http(s)://[Endpoint]/?Action=TranslateGeneral
&FormatType=text
&Scene=general
&SourceLanguage=zh
&SourceText=你好
&TargetLanguage=en
&<公用請求參數>
正常返回樣本
XML
格式
<TranslateGeneralResponse>
<RequestId>14E447CA-B93B-4526-ACD7-42AE13CC2AF6</RequestId>
<Data>
<Translated>Hello</Translated>
</Data>
<Code>200</Code>
</TranslateGeneralResponse>
JSON
格式
{
"TranslateGeneralResponse": {
"RequestId": "14E447CA-B93B-4526-ACD7-42AE13CC2AF6",
"Data": {
"Translated": "Hello"
},
"Code": 200
}
}
錯誤碼
HttpCode | 錯誤碼 | 錯誤資訊 | 描述 |
101 | 10001 | The request has timed out. | 請求逾時 |
102 | 10002 | A system error occurred. | 系統錯誤 |
103 | 10003 | An error occurred while decoding the URL. Verify that the specified URL is encoded. | 原文解碼失敗,請檢查原文是否UrlEncode |
104 | 10004 | Some required parameters are missing. | 參數缺失 |
105 | 10005 | The specified language pair is not supported. | 語項不支援 |
106 | 10006 | An error occurred while detecting the language. | 語種識別失敗 |
107 | 10007 | An error occurred while translating. | 翻譯失敗 |
108 | 10008 | The specified string is too long. | 字元長度過長 |
199 | 19999 | An unknown error occurred. | 未知異常 |
109 | 10009 | 子帳號沒有許可權 | 子帳號沒有許可權 |
110 | 10010 | 帳號沒有開通服務 | 帳號沒有開通服務 |
111 | 10011 | 子帳號服務失敗 | 子帳號服務失敗 |
112 | 10012 | 翻譯服務調用失敗 | 翻譯服務調用失敗 |
113 | 10013 | 帳號服務沒有開通或者欠費 | 帳號服務沒有開通或者欠費 |
訪問錯誤中心查看更多錯誤碼。