跳到主要内容

机器翻译API

接口描述​

机器翻译接口。

请求说明​

URL​

https://openapi.sys303.com/api/cognitive/translation

参数​

Header参数​
参数值
Content-Typeapplication/json
X-Secret点击获取
Body参数​
参数是否必选类型可选值范围说明
sourceLang是int[0, 1]待翻译语言类型 【0:藏文,1:中文】
destLang是int[0, 1]目标翻译语言类型 【0:藏文,1:中文】
inputText是string-待翻译文字【unicode 长度3000字以内】

请求样例​

  curl --request POST \       
--url https://openapi.sys303.com/api/cognitive/translation \
--header 'Content-Type: application/json' \
--header 'X-Secret: {X-Secret}' \
--data '{
"sourceLang": 1,
"destLang": 0,
"inputText": "你好"
}'

返回说明​

参数说明​

字段是否必选类型状态说明
traceId是String-唯一的traceId,用于问题定位
msgId是String-业务状态码
msg是String错误描述
data是String-翻译结果

返回样例​

成功​
{
"traceId": "0HNL06O44AV58:00000001",
"msgId": "2000000",
"msg": "success",
"data": "ཁྱོད་བདེ་མོ།"
}
失败​

认证失败:

{
"traceId": "0HNLN3J9DCJSE:00000001",
"msgId": "4011001",
"msg": "AuthFailed",
"data": null
}

传入参数错误:

{
"traceId": "0HNL06O44AUV9:00000001",
"msgId": "500",
"msg": "Specified argument was out of the range of valid values. (Parameter 'source') Actual value was BoAll.",
"data": null
}

字符长度超长:

{
"traceId": "0HNL06O44AUVB:00000001",
"msgId": "4004002",
"msg": "InputTooLong",
"data": null
}

翻译字符数不足:

{
"traceId": "0HNL06O44AUO9:00000001",
"msgId": "2001001",
"msg": "InsufficientInventory",
"data": null
}