翻译 API
我们提供30个引擎的自动翻译API。
账号信息
你购买之后,我们将为你提供以下两个账号验证api参数,以下提供测试用参数值。
参数名 | 测试用值 |
---|---|
license |
TESTTESTTEST |
apiKey |
51b86206-3b2d-d9a9-20e5-08e177b03f48 |
你可随时登录 https://gt4t.net/en/gt4t_manager.php 查看流量使用信息。
连接方式
简单 get
连接
使用 get
将参数附加在 url 上发起请求。
请求参数列表
参数名 | 测试用值 | 是否必选 | 说明 |
---|---|---|---|
license |
TESTTESTTEST |
必选 | 账号许可代码 |
apiKey |
51b86206-3b2d-d9a9-20e5-08e177b03f48 |
必选 | api秘钥 |
tl |
zh-cn |
必选 | 目标语言代码,zh-cn 代表翻译成简体中文,取值详见下文 |
text |
I%20like%20this%20game. |
必选 | 要翻译的文字,需要先 uriencode |
engine |
5 |
可选 | 引擎代码,例如5 为deepl ,详见下文,不提供,系统则会根据语言对自动选择引擎 |
sl |
en |
可选 | 源语言代码,en 代表要翻译的文字为英文,取值详见下文。不提供则自动检测,自动检测会额外扣除字符 |
scene |
not_specified |
可选 | 指定风格或行业的code值,详见下文。不是所有引擎都支持所有行业。 |
简单 get
方式请求示例
curl "https://api.gt4t.cc/translate?apiKey=51b86206-3b2d-d9a9-20e5-08e177b03f48&license=TESTTESTTEST&sl=en&tl=zh-cn&text=I%20like%20this%20game.&engine=5&scene=not_specified"
简单 post
连接
以 post 的方式提交 json object
到端点 https://api.gt4t.cc/translate
参数名 | 测试用值 | 是否必选 | 说明 |
---|---|---|---|
license |
TESTTESTTEST |
必选 | 账号许可代码 |
apiKey |
51b86206-3b2d-d9a9-20e5-08e177b03f48 |
必选 | api秘钥 |
tl |
zh-cn |
必选 | 目标语言代码,zh-cn 代表翻译成简体中文,取值详见下文。 |
text |
I like this game. |
必选 | 要翻译的文字,不要 uriencode |
engine |
5 |
可选 | 引擎代码,例如5 为deepl ,详见下文,不提供,系统则会根据语言对自动选择引擎 |
sl |
en |
可选 | 源语言代码,en 代表要翻译的文字为英文,取值详见下文。不提供则自动检测,自动检测会额外扣除字符 |
scene |
not_specified |
可选 | 指定风格或行业的code值,详见下文。不是所有引擎都支持所有行业。 |
简单post
方式请求示例
curl -d '{"license":"TESTTESTTEST", "apiKey":"51b86206-3b2d-d9a9-20e5-08e177b03f48","sl":"en", "tl": "zh-cn", "text": "I love this game", "engine": "5", "scene": "not_specified"}' -H "Content-Type: application/json" -X POST https://api.gt4t.cc/translate
安全 post
连接
此连接方式使用签名方式,发送请求时不传递apiKey
,确保apiKey
不被中间攻击截取。
参数名 | 测试用值 | 是否必选 | 说明 |
---|---|---|---|
license |
TESTTESTTEST |
必选 | 账号许可代码 |
salt |
h2rsowk8nv |
必选 | 任意随机字符串 |
md5 |
c748a656be88cd1f82134ce38d92c707 |
必选 | 签名字符串,生成方式见下文 |
tl |
zh-cn |
必选 | 目标语言代码,zh-cn 代表翻译成简体中文,取值详见下文。 |
text |
I like this game. |
必选 | 要翻译的文字,不要 uriencode |
engine |
5 |
可选 | 引擎代码,例如5 为deepl ,详见下文,不提供,系统则会根据语言对自动选择引擎 |
sl |
en |
可选 | 源语言代码,en 代表要翻译的文字为英文,取值详见下文。不提供则自动检测,自动检测会额外扣除字符 |
scene |
not_specified |
可选 | 指定风格或行业的code值,详见下文。不是所有引擎都支持所有行业。 |
md5 签名生成方式
- 生成任意随机字符串作为
salt
参数
const hayStack='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
const salt = Array(5).join().split(',').map(function() { return hayStack.charAt(Math.floor(Math.random() * hayStack.length)); }).join('');
- 获取当前秒级
unix 时间戳
除以300后,向下取整。
//Data.now 返回毫秒,所以需要先除以 1000
const timeStamp = Math.floor(Date.now() / 1000 / 300);
- 将
license
,salt
,apiKey
,timeStamp
合并字符串后取小写md5值,即获得签名
const license = "TESTTESTTEST"
const apiKey = "51b86206-3b2d-d9a9-20e5-08e177b03f48"
const hayStack='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
const salt = Array(5).join().split(',').map(function() { return hayStack.charAt(Math.floor(Math.random() * hayStack.length)); }).join('');
const timeStamp = Math.floor(Date.now() / 1000 / 300);
const raw = `${license}${salt}${apiKey}${timeStamp}`
const cryptoJS = require("crypto-js");
const md5= cryptoJS.MD5(raw).toString()
安全 post
方式请求示例
以 post 的方式将参数提交 json object
到端点 https://api.gt4t.cc/translate
curl -d '{"license": "TESTTESTTEST","salt": "h2rsowk8nv","md5": "c748a656be88cd1f82134ce38d92c707","tl": "zh-cn","text": "I like this game.","engine": "5","scene": "not_specified"}' -H "Content-Type: application/json" -X POST https://api.gt4t.cc/translate
API返回数据
请求成功,api返回http
状态码200,并返回以下json
值
{
"status": "OK",
"detectedSourceLan": "",
"engineNo": "5",
"engineName": "DeepL Pro",
"translations": [
"我喜欢这个游戏"
],
"charsCount": 16,
"charsDeducted": 16,
"charsRemaining": 48562
}
请求失败,api返回标准http
错误码
语言代码列表
{"ab": "Abkhazian (Абхаза)","knj": "Acateco (Akateko)","ace": "Aceh (Aseh)","acr": "Achi","acu": "Achuar","adh": "Adhola","af": "Afrikaans","any": "Agni Sanvi","duo": "Agta Eastern Cagayan","agr": "Aguaruna","ak": "Akan","ake": "Akawaio","sq": "Albanian","amk": "Ambai","am": "Amharic","amu": "Amuzgo","ar": "Arabic (العربية)","an": "Aragonese","hy": "Armenian","cpb": "Ashéninka","as": "Assamese","ast": "Asturian","aym": "Aymara","az": "Azerbaijani","azb": "Azerbaijani South","bdh": "Baká","bal": "Baluchi","ptu": "Bambam","bam": "Bambara","bqj": "Bandial","bno": "Bantoanon","bsn": "Barasana","bfa": "Bari","bch": "Bariai","bba": "Bariba","ba": "Bashkir","eu": "Basque","be": "Belarusian","bem": "Bemba","bn": "Bengali (বাংলা)","ber": "Berber","bho": "Bhojpuri","bi": "Bislama","byn": "Blin","bus": "Bokobaru","bnp": "Bola","bs": "Bosnian (bosanski)","br": "Brezhoneg","bg": "Bulgarian (Български)","bqp": "Busa","cjp": "Cabecar","cak": "Cakchiquel","cni": "Campa","kbh": "Camsa","yue": "Cantonese (粵語)","ca": "Catalan (Català)","ceb": "Cebuano","nch": "Central Huasteca Nahuatl","ccp": "Chakma","cha": "Chamorro","cbk": "Chavacano","che": "Chechen","chr": "Cherokee","ny": "Chewa (Nyanja)","cbl": "Chin Bualkhaw","cfm": "Chin Falam","cnh": "Chin Hakha","ctd": "Chin Tedim","czt": "Chin Zotung","chq": "Chinantec","zh-py": "Chinese Pinyin (汉语拼音)","zh-cn": "Chinese Simplified (简体中文)","zh-tw": "Chinese Taiwan (臺灣繁體中文)","zh-hk": "Chinese HK (港澳繁體中文)","zh-dl": "Chinese Traditional (大陸繁體中文)","zh-lit-jian": "Chinese Literary Simp. (简体文言文)","zh-lit-fan": "Chinese Literary Trad. (繁體文言文)", "cdf": "Chiru","cv": "Chuvash","cop": "Coptic","kw": "Cornish","co": "Corsican","mus": "Creek","hwc": "Creole English Hawai’i","ht": "Creole Haitian","crs": "Creole Seychelles","hr": "Croatian (Hrvatski)","cs": "Czech (Čeština)","mps": "Dadibi","da": "Danish (Dansk)","fa-af": "Dari","dik": "Dinka","tbz": "Ditammari","dv": "Divehi (Dhivehi)","dtp": "Dusun Central","nl": "Dutch (Nederlands)","dyu": "Dyula","dz": "Dzongkha","en": "English","en-gb": "English British","enx": "Enxet","eo": "Esperanto","et": "Estonian (Eesti)","ee": "Ewe","fo": "Faroese","fj": "Fijian","fil": "Filipino","fi": "Finnish (Suomi)","gur": "Frafra","fr": "French (Français)","fr-ca": "French Canada","fy": "Frisian","fur": "Friulian","fuv": "Fulfulde Nigerian","fvr": "Fur","gd": "Gaelic Scottish","gbi": "Galela","gl": "Galician","krs": "Gbaya","ka": "Georgian","de": "German (Deutsch)","gof": "Goffa","gbo": "Grebo Northern","el": "Greek (Ελληνικά)","gos": "Gronings","gub": "Guajajára","gn": "Guarani","gnw": "Guaraní Western Bolivian","gu": "Gujarati (ગુજરાતી)","hlb": "Halbi","ha": "Hausa","haw": "Hawaiian","he": "Hebrew (עברית)","hil": "Hiligaynon","hi": "Hindi (हिंदी)","hmn": "Hmong","huv": "Huave San Mateo del Mar","hui": "Huli","hu": "Hungarian (Magyar)","hup": "Hupa","iba": "Iban","is": "Icelandic (Íslenska)","io": "Ido","ify": "Ifugao Antipolo","ifb": "Ifugao Ayangan","ifa": "Ifugao Central","ig": "Igbo","ikk": "Ika","ilo": "Iloko","id": "Indonesian","inh": "Ingush","ia": "Interlingua","ie": "Interlingue","iu": "Inuktitut","ga": "Irish (Gaeilge)","it": "Italian (Italiano)","izz": "Izi","jac": "Jakalteko","ja": "Japanese (日本語)","jv": "Javanese","kac": "Jingpho","kab": "Kabyle","keo": "Kakwa","kl": "Greenlandic (Kalaallisut)","xal": "Kalmyk-Oirat","kdx": "Kam","kn": "Kannada (ಕನ್ನಡ)","kr": "Kanuri","kpg": "Kapingamarangi","cki": "Kaqchikel","xsm": "Kasem","ks": "Kashmiri","csb": "Kashubian","pss": "Kaulong","kyu": "Kayah Western","kk": "Kazakh Cyrillic (Қазақ, 哈萨克语)","kk-ara": "Kazakh Traditional (قازاقشا, 哈萨克语)","kbo": "Keliko","kha": "Khasi","km": "Khmer","quc": "Kiche","kg": "Kikongo (Kongo)", "ki": "Kikuyu", "rw": "Kinyarwanda","gil": "Kiribati (Gilbertese)","rn": "Kirundi (Rundi)","jmc": "Kisiha","tlh-latn": "Klingon Latin","tlh-piqd": "Klingon piqd","ko": "Korean (한국어)", "ko-north": "Korean North (한국어)", "ksd": "Kuanua","kle": "Kulung","ku": "Kurdish Latin (Kurdî)","ckb":"Kurdish Sorani (کوردی)", "kj": "Kwanyama", "ky": "Kyrgyz (Kirghiz)","lsi": "Lacid","lo": "Lao (ລາວ)","ltg": "Latgalian","la": "Latin","lv": "Latvian (Latviešu)","lcp": "Lawa Western","li": "Limburgish","ln": "Lingala","ond": "Lingao","lfn": "Lingua Franca Nova","lt": "Lithuanian (Lietuvių)","jbo": "Lojban","ngl": "Lomwe","nds": "Low German","lu": "Luba-Katanga", "lg": "Luganda (Ganda)","dop": "Lukpa","lnd": "Lun Bawang","lb": "Luxembourgish (lëtzebuergesch)","mdy": "Maale","mk": "Macedonian","mad": "Madurese","mai": "Maithili","mg": "Malagasy","ms": "Malay (Melayu)","ml": "Malayalam (മലയാളം)","mt": "Maltese (Il-Malti)","mam": "Mam","map": "Mam Northern","mni": "Manipuri","mbb": "Manobo Western Bukidnon","gv": "Manx","mi": "Maori (Māori)","mrw": "Maranao","mr": "Marathi (मराठी)","mhr": "Mari","mrj": "Mari Hill","mah": "Marshallese","yua": "Maya Yucatec","mn": "Mongolian Cyrillic (Монгол 蒙古语)","mo": "Mongolian Traditional (ᠮᠣᠩᠭᠣᠯ ᠬᠡᠯᠡ 蒙古语)","cnr": "Montenegrin","me": "Montenegro","mfe": "Morisyen","mos": "Mossi","meu": "Motu","hmo": "Motu Hiri","tih": "Murut Timugon","muv": "Muthuvan","my": "Myanmar (Burmese, ဗမာစာ)","nhg": "Nahuatl","ntm": "Nateni","nv": "Navajo", "nd": "Ndebele Northern", "nr":"Ndebele Southern", "ng": "Ndonga", "djk": "Ndyuka","ne": "Nepali","niu": "Niuean","se": "Sami Northern", "sma": "Sami Southern", "no": "Norwegian Bokmal", "nn": "Norwegian Nynorsk", "nop": "Numanggang","nyy": "Nyakyusa","oc": "Occitan","ojb": "Ojibwa","or": "Oriya (Odia)","bdu": "Oroko","om": "Oromoo","os": "Ossetic","otq": "Otomi Queretaro","pck": "Paite","pmn": "Pam","pag": "Pangasinan","pap": "Papiamento","ps": "Pashto (پښتو)","ata": "Pele-Ata","fa": "Persian (Farsi, فارسی)","pl": "Polish (Polski)","poh": "Poqomchi’","pt-pt": "Portuguese (Português)","pt-br": "Portuguese Brazil","pot": "Potawatomi","pa": "Punjabi (ਪੰਜਾਬੀ)","kek": "Qeqchi (Kekchí)","quz": "Quichua Cusco","quh": "Quichua South Bolivian","quw": "Quichua","qxr": "Quichua Cañar Highland","rmn": "Romani","ro": "Romanian (Română)","rm": "Romansh","rom": "Romany","rug": "Roviana","ru": "Russian (Русский)","rue": "Rusyn","spy": "Sabaot","ssx": "Samberigi","sm": "Samoan","sg": "Sango","sa": "Sanskrit","sco": "Scots","sr-cyrl": "Serbian (Српски)","sr-latn": "Serbian Latin (Srpski)","hbs": "Serbo-Croatian","st": "Sesotho","shn": "Shan","shp": "Shipibo","sn": "Shona","jiv": "Shuar","sid": "Sidamo","szl": "Silesian","sd": "Sindhi","si": "Sinhala (Sinhalese)","ssd": "Siroi","sk": "Slovak (Slovenčina)","sl": "Slovenian (Slovenščina)","so": "Somali","es": "Spanish (Español)","es-mx": "Spanish LAC","es-us": "Spanish United States","swp": "Suau","su": "Sundanese","sw": "Swahili (Kiswahili)", "ss": "Swati", "sv": "Swedish (Svenska)","syc": "Syriac","shi": "Tachelhit","tl": "Tagalog","ty": "Tahitian","tg": "Tajik","tmh": "Tamajaq","ta": "Tamil (தமிழ்)","tpm": "Tampulma","tt": "Tatar","crh": "Tatar Crimean","te": "Telugu (తెలుగు)","tex": "Tennet","teo": "Teso","tet": "Tetun","th": "Thai (ไทย)","ti": "Tibetic (བོད་སྐད།, 藏语)","tig": "Tigre","tir": "Tigrinya","tpi": "Tok Pisin","toi": "Tonga (Zambia)","to": "Tongan (lea fakatonga)","cas": "Tsimané","tn": "Tswana","iou": "Tuma-Irumu","lcm": "Tungag","tr": "Turkish (Türkçe)","tk": "Turkmen","tvl": "Tuvalu","tyv": "Tuvan","tw": "Twi","udm": "Udmurt","uk": "Ukrainian (Українська)","ppk": "Uma","umb": "Umbundu","hsb": "Upper Sorbian","ur": "Urdu (اردو)","usp": "Uspanteco","uy": "Uyghur (ئۇيغۇرچە,维吾尔语)","uy-latin": "Uyghur Latin (Uyghur,维吾尔语)","uz": "Uzbek (O'zbek)","ve": "Venda","vi": "Vietnamese (Tiếng Việt)","vo": "Volapük", "vro": "Võro", "vun": "Vunjo","prk": "Wa","wlx": "Wali","wa": "Walloon","war": "Waray","wrs": "Waris","wsk": "Waskia","cy": "Welsh","wal": "Wolaytta","wol": "Wolof","xh": "Xhosa","ts": "Xitsonga (Tsonga)","jae": "Yabem","sah":"Yakut (Саха тыла)","ii": "Yi (ꆈꌠꉙ彝)","yi": "Yiddish","byr": "Yipma","pil": "Yom","yon": "Yongkom","yo": "Yoruba","dje": "Zarma","zza": "Zaza","za": "Zhuang (壮)","zyb": "Zhuang Yongbei (邕北壮)","zu": "Zulu"}
引擎列表
{
"0": "谷歌翻译 (Google)",
"1": "微软 (Microsoft)",
"2": "有道",
"3": "Yandex",
"5": "DeepL Pro",
"6": "百度",
"7": "腾讯翻译君",
"9": "云译",
"10": "小牛翻译",
"11": "Systran*",
"12": "TradooIT",
"13": "Naver Papago",
"14": "云上曲率",
"15": "LingvaNex",
"16": "腾讯TranSmart",
"17": "澜舟",
"18": "彩云小译",
"19": "Amazon Translate",
"20": "阿里机译",
"21": "讯飞",
"22": "IBM Watson Translator",
"23": "ModernMT",
"24": "MyMemory",
"25": "火山翻译",
"26": "Tilde",
"27": "Neurotõlge",
"28": "Atman",
"29": "新译",
"30": "同花顺"
}
风格或行业列表
[
{ code: "it", info: "IT及电子" },
{ code: "genericplus", info: "通用增强" },
{ code: "medical", info: "医学-通用" },
{ code: "formal", info: "正式" },
{ code: "informal", info: "非正式" },
{ code: "eu_council", info: "欧盟理事会主席" },
{ code: "law", info: "法律" },
{ code: "hardware", info: "硬件" },
{ code: "finance", info: "金融财务" },
{ code: "patent", info: "专利" },
{ code: "automotive", info: "汽车" },
{ code: "coronacrisiscorpus", info: "新冠危机语料库" },
{ code: "education", info: "教育" },
{ code: "financeKern", info: "财务,由Kern提供" },
{ code: "generic_loca_gb", info: "Generic en-GB" },
{ code: "manufacturing", info: "制造" },
{ code: "Automotive", info: "汽车" },
{ code: "generic_loca_ca", info: "Generic fr-CA" },
{ code: "legal-frca", info: "Legal fr-CA" },
{ code: "itMozilla", info: "IT,由Mozilla提供" },
{ code: "generic_loca_mx", info: "Generic es-US/MX" },
{ code: "legalCrosslang", info: "法律,由Crosslang提供" },
{ code: "oral", info: "口语" },
{ code: "agribusiness", info: "农业" },
{ code: "genericTerminotix", info: "通用,由Terminotix提供" },
{ code: "genericQ-Lingua", info: "通用,由Q-Lingua提供" },
{ code: "energy", info: "能源" },
{ code: "genericCrosslang", info: "通用,由Crosslang提供" },
{ code: "it_loca_br", info: "IT pt-BR" },
{ code: "it_loca_pt", info: "IT pt-PT" },
{ code: "oil-and-gas", info: "石油天然气" },
{ code: "generic_cyrillic-script", info: "Generic Cyrillic script" },
{ code: "generic_latin-script", info: "Generic Latin script" },
{ code: "genericDragoman", info: "通用,由Dragoman提供" },
{ code: "engineer", info: "工程" },
{ code: "novel", info: "网络文学" },
{ code: "title", info: "电子商务:产品名称" },
{ code: "description", info: "电子商务:产品说明" },
{ code: "communication", info: "电子商务:通信" },
{ code: "social", info: "社交" },
{ code: "finance-announcement", info: "金融:公告" },
{ code: "dissertation", info: "学术文献" },
{ code: "military", info: "军事" },
{ code: "politics", info: "新闻政治" },
{ code: "IT", info: "IT及电子" },
{ code: "machinery", info: "机械" },
{ code: "geography", info: "地理" },
{ code: "transportation", info: "交通" },
{ code: "chemistry", info: "化工" },
{ code: "architecture", info: "建筑" },
{ code: "auto", info: "汽车" },
{ code: "aviation", info: "航空" },
{ code: "tcm", info: "中药" },
{ code: "tourism", info: "旅游" },
{ code: "medical-pv", info: "医学-药物警戒" },
{ code: "medical-device", info: "医学-医疗器械" },
{ code: "medical-cmc", info: "医学-CMC" },
{ code: "medical-clinical", info: "医学-临床" },
{ code: "medical-nonclinical", info: "医学-非临床" },
{ code: "medical-regulation", info: "医学-法规" },
{ code: "internet", info: "网络口语" },
{ code: "generic_loca_ch", info: "Generic de-CH" },
{ code: "sciencetechnology", info: "科学和技术" }
]