0
votes

I just started using Google Translate API for the first time, yet my requests are denied due to 403 Forbidden "User Rate Limit Exceeded". How is this possible?? According to the cloud console, I have generated only a few requests, but they have all been errors. Here is a screenshot where I got that info:

enter image description here

Also, Google says that none of my quotas seem to be exceeded:

enter image description here

Seems impossible that I could be exceeding any quote from just 5 requests. How can I better understand why I'm getting "User Rate Limit Exceeded", and how to make it stop happening?

As far as I can tell, I was using the default quotas. I've never been able to successfully make a call (using the official Python library). I later slightly decreased the quota just for funzies (the default is the maximum allowed value), but that didn't help.

Here is the exact code that I used:

>>> import six
>>> from google.cloud import translate_v2 as T
>>> c = T.Client()
>>> t = "The rain in Spain."
>>> r = c.translate(t, target_language='es')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/allyourcode/.local/lib/python2.7/site-packages/google/cloud/translate_v2/client.py", line 268, in translate
    response = self._connection.api_request(method="POST", path="", data=data)
  File "/home/allyourcode/.local/lib/python2.7/site-packages/google/cloud/_http.py", line 483, in api_request
    raise exceptions.from_http_response(response)
google.api_core.exceptions.Forbidden: 403 POST https://translation.googleapis.com/language/translate/v2?prettyPrint=false: User Rate Limit Exceeded
2

2 Answers

1
votes

Figured it out! The problem was that the project was assigned to a defunct billing account. Unsurprisingly, by changing the billing account of the project to a non-defunct billing account, I was able to get a successful response to my requests. The error reason is pretty unhelpful!

0
votes

Translation API limits The API limits in three ways: characters per day, characters per 100 seconds, and API requests per 100 seconds. All can be set in the API manager in Google Cloud console: https://console.developers.google.com/apis/api/translate.googleapis.com/quotas

The library will limit the API calls for the characters and API requests per 100 seconds. The API will automatically retry if you are making requests too quickly, and also pause to make sure you only send 100000 characters per 100 seconds.