artemave / translate_onhover

Browser translation extension
https://chrome.google.com/webstore/detail/aggiiclaiamajehmlfpkjmlbadmkledi
205 stars 61 forks source link

Requests to translate.googleapis.com/translate_a/single fail with status 429 #74

Closed rioam2 closed 3 years ago

rioam2 commented 3 years ago

Hello! Firstly, thank you so much for this helpful extension. It has saved me countless hours of work translating and switching tabs!

Within the past few days, I've noticed that the extension will sometimes have issues providing a translation. By inspecting the extension's service worker, I see several XHR requests to https://translate.googleapis.com/translate_a/single fail with status code 429 and the following body:

Our systems have detected unusual traffic from your computer network. Please try your request again later. 

This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the Terms of Service. The block will expire shortly after those requests stop. This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.  If you share your network connection, ask your administrator for help - a different computer using the same IP address may be responsible.  

Is there a reason for moving away from using https://clients5.google.com/translate_a/t in commit e069aded9fa98dd7583076b67a8940ff2a5f549d? I notice that when the new API is rate-limited, I can still successfully make requests to the old API without being rate-limited.

Best 😃

artemave commented 3 years ago

I can still successfully make requests to the old API without being rate-limited

Yeah, but it started to return different data (in different format and only single word translations as far as I could see) hence the change.

Are you saying that the extension is working without problems using old api url?

rioam2 commented 3 years ago

Makes sense, I wasn't aware the API had changed. I have been using Postman to inspect the API 🤔

I am able to get a full sentence translation with the following request: GET https://clients5.google.com/translate_a/t?client=dict-chrome-ex&q=jeg heter rio&sl=no&tl=en&ie=UTF8&oe=UTF8 -->

[
    [
        [
            [
                [
                    "my name is rio"
                ]
            ],
            null,
            "no"
        ]
    ]
]
urfausto commented 3 years ago

shitty goolag came up with a querie limitation, you can check that with this extension that uses multiple translation engines: https://chrome.google.com/webstore/detail/xtranslate/gfgpkepllngchpmcippidfhmbhlljhoo make a translation and it appears with 2 engines but fails with goolag

artemave commented 3 years ago

I am able to get a full sentence translation with the following request

Yeah, but I wasn't able to get a "full" translation for a single word (multiple translations, part of speech, etc.)

artemave commented 3 years ago

shitty goolag came up with a querie limitation, you can check that with this extension that uses multiple translation engines: https://chrome.google.com/webstore/detail/xtranslate/gfgpkepllngchpmcippidfhmbhlljhoo make a translation and it appears with 2 engines but fails with goolag

That's interesting. But as far as I can see, yandex is also a paid api, and so they'll probably protect their api as well.

I also don't feel like calling Google names is appropriate in this instance. They've got a great product and they want money for it. Furthermore, they're giving third party developers a chance to make money on top of their API (something that one can't realistically do with free stuff).

WSHBRN commented 3 years ago

Hi @artemave, I agree with your statement above. Could you share some update how TransOver is gonna work now? For now extension works for let's say 2 hours, then stop for few hours. And it's happening over and over. Is there any way to keep it avilable all the time as previously? Any workaround for that (even paid)? thx!

rioam2 commented 3 years ago

I am able to get a full sentence translation with the following request

Yeah, but I wasn't able to get a "full" translation for a single word (multiple translations, part of speech, etc.)

Ahh, I see. Maybe they've updated this information to be available on a separate endpoint. Do you know how you discovered this "clients5" endpoint originally?

In the meantime, maybe we can use the old API as a fallback when the new one becomes rate limited? While the part of speech and per-word information will not be available, users can still see the translation, which I belive will satisfy the needs of most users.

urfausto commented 3 years ago

anyway google translate is not even this so good translator, i've found bing to be more accurate while using it...

both have API fees though: https://www.linnworks.com/blog/google-bing-translate

artemave commented 3 years ago

Could you share some update how TransOver is gonna work now? For now extension works for let's say 2 hours, then stop for few hours. And it's happening over and over. Is there any way to keep it avilable all the time as previously? Any workaround for that (even paid)? thx!

I think I am going to have to bite the bullet and switch to the proper paid API. To start with, current rate limited API can act as default "free tier". And then whoever finds themselves exceeding rate limit, will have an option to sign up and switch to the paid version.

This is not going to happen overnight though. So I might first implement @rioam2 suggestion to fallback to "single word" API in case of rate limit. Though it's arguably a bit of a confusing UX. What do you people think?

Also, as someone who has never been able to hit the rate limit, can I ask you how you're using Transover? It would help me a great deal to hear some user stories. Thanks!

WSHBRN commented 3 years ago

I use it only fortranslation (with text-to-speech disabled) pointing at a single word or selected setences, rarely for blocks of text that consists of multiple sentences. But sometimes you may unintentioanlly select huge block of text (entire page) and translate it moving your mouse. Maybe that causes the problem with limit.

I reach limit now after ~1 hour of using extension sporadically.

Could you share how you use it without exceeding rate limit?

rioam2 commented 3 years ago

I use the extension for remote work with a company in another country. I'm not fully proficient in the foreign language, so I generally use the point-to-translate feature (also with text-to-speech disabled) to translate Slack messages (whole sentences, commonly with multiple sentences). I rarely translate single words individually. I usually translate ~100 separate sentences within a short period of time when I start my work day, and then a bit more throughout the day at a more reasonable pace.

I will sometimes accidentally translate a single word when letting my mouse rest on the screen, but I realize I can easily avoid that by setting a keypress to activate the translations.

metaflow commented 3 years ago

does rate-limiting happen to you for a specific API key? I personally will be OK with jumping through hoops to get my own key to avoid being rate limited

artemave commented 3 years ago

@metaflow there is no API key at the moment - we're just stealing an endpoint used by Google Translate chrome extension. Which is naughty, but there you go.

artemave commented 3 years ago

Could you share how you use it without exceeding rate limit?

So I ran this yesterday evening and it started to fail around ATTEMPT 40. This morning it let me go as far as 80 before rate limit kicked in.

for n in {1..200}; do echo "----------\n ATTEMPT $n\n"; curl -f -vvv 'https://translate.googleapis.com/translate_a/single?client=gtx&dt=t&dt=bd&dj=1&source=input&q=language&sl=en&tl=fr' \
  -H 'authority: translate.googleapis.com' \
  -H 'accept: application/json, text/javascript, */*; q=0.01' \
  -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36' \
  -H 'sec-fetch-site: none' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-dest: empty' \
  -H 'accept-language: en-US,en;q=0.9' \
  --compressed || break; done
urfausto commented 3 years ago

i mostly use long texts translation...

WSHBRN commented 3 years ago

Hi there, after 2 days of uninterrupted work TransOver and XTranslate (based on google) have crashed. @artemave, could you post brief update what happened?

turiandras commented 3 years ago

Hi! First of all, I'm also very grateful for this extension, thanks! This is just the best UX I've had so far when trying to read any web content in a language that I don't know completely.

My main use case nowadays is reading any German text (news, wikipedia, emails): I have a basic understanding, but lots of words are unknown to me. I'd like to improve, so whenever I see words I don't fully understand I just double click it / select them and have the translation right there. To be able to understand any word/expression this fast and simple, it feels like magic..

Unfortunately this means that whenever I go down de.wikipedia, I hit the rate limit pretty fast.

For me, the fallback to the old API sounds reasonable. To be honest I didn't even realize the advanced features served by the new API exist. When the fallback happens, a small red warning somewhere could explain and prevent any confusion.

Also, if necessary, I'd be up for becoming a paying user, I recognize I'm being provided a valuable service.

artemave commented 3 years ago

First of all, I'm also very grateful for this extension, thanks!

Thank you for the kind words. And also thank you for sharing your user story.

Also, if necessary, I'd be up for becoming a paying user, I recognize I'm being provided a valuable service.

Yeah, I am inclined to go that route. How much would you pay for that service?