Google 翻译免费 API

Google 翻译免费 API

我一直调用 google 收费的 api,但是 100 万字 需要 20 美元,如果是万字长文的话,每调用一次接近 3 块钱,自从我的翻译上线来,免费额度(50 万字)已经用完了,有一个用户一天就用了差不多 20 万字和额度,今天看到有人调用 google 翻译的免费 api,大概看了一下,确实能用,不过用起来不是特别方便,好像是基于句子的,不能一次把整个文档给他,但是我想稍加修改,也够用了。

调用方式一

直接在浏览器请求就可以,返回的是一个 json ,格式如下。

    https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=auto&tl=zh-cn&q=To help, we’ve got all the best trying-to-conceive tips right here. Read on for the scoop on everything you need to know about how to get pregnant, from your odds of conceiving to what you can do to have a healthier pregnancy right from the start. Happy baby-making!
20211230vMgb49

参数说明

  1. clinet 为必填参数,值为 dict-chrome-ex
  2. sl 为必填参数,值为 auto,表示自动检测语言
  3. tl 为必填参数,值为 zh-cn,表示翻译成中文
  4. q 为必填参数,值为你要翻译的内容。

注意事项

  1. 他会自动切分句子,如果是一段很长的内容,他会切合成一个句子的数组,然后返回。

调用方式二

https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=zh-CN&dj=1&dt=t&dt=bd&dt=qc&dt=rm&dt=ex&dt=at&dt=ss&dt=rw&dt=ld&q=The%20last%20step%20for%20the%20popup%20UI%20is%20adding%20color%20to%20the%20button&tk=233819.233819

这几个参数还没有弄明白,只是初看了一下,github上面有很多人在讨论这个 api, Found a Google Translate endpoint that doesn’t require an API key

发表评论