17

I am using translate API to translate some texts in my page, those texts are large html formated texts, so I had to develop a function that splits these texts into smaller pieces less than 4500 characters (including html tags) to avoid the limit of 5000 characters per request, also I had to modify the Google PHP API to allow send requests via POST.

I have enabled the paid version of the api in Goole Developers Console, and changed the total quota to 50M of characters per day and 500 requests/second/urser.

Now I am translating the whole database of texts with a script, it works fine but at some random points I revive the error "(403) User Rate Limit Exceeded", and I have to wait some minutes to re-run the script because when reached the error the api is returning the same error over and over until I wait some time.

I don't know why it keeps returning the error if I don't pass the number of requests, it's like it has some kind of maximum chaaracters per each interval of time or something...

David Rojo
  • 2,337
  • 1
  • 22
  • 44

6 Answers6

12

You probably exceed the quota limits you set before: this is either the daily billable or the limit on the request characters per second.

To change the usage limits or request an increase to your quota, do the following: 1. Go to the Google Developers Console "https://console.developers.google.com/". 2. Select a project. 3. On the left sidebar, expand APIs & auth. 4. Click APIs. 5. Click the name of an activated API you're interested in "i.e. The Translate API". 6. Near the top of the info page for the API, click Quota.

  • If you have the billing enabled, just click Quota and it will take you to the quota page where you can view and change the quota-related settings.

  • If not, clicking Quota shows information about any free quota and limits that apply to the Translate API.

Mohab
  • 153
  • 6
  • This worked great, every where else I Googled didn't have an answer – Daniel Aug 05 '15 at 11:34
  • @mohab unfortunately this is not true. I get this same error once in a while even though the number of requests are less than 1% of the quota. the main reason is that Google APIs are crapy. I have been using almost all Google APIs since 2012, different versions and version after version they get crappier and crappier. – Allen King May 29 '16 at 17:20
  • 1
    This may have something to do with a particular Google App domain. Believe there is a 10 requests per second limit per user. Google API is garbage because it just doesn't work as it should work. Our more active users are having this issue, pretty much makes the whole integration useless – Allen King Jul 06 '16 at 20:20
  • I need help with something related to quota exceeded: https://stackoverflow.com/questions/45324747/google-drive-api-quota-exceeded – Lechucico Jul 26 '17 at 10:53
2

Google Developer Console has a rate limit of 10 requests per second, regardless of the settings or limits you may have changed.

You may be exceeding this limit.

I was unable to find any documentation around this, but could verify it myself with various API requests.

Jess Telford
  • 12,880
  • 8
  • 42
  • 51
1

You control the characters limitation but not the concurrency

You are either making more than 500 concurrent request/second or you are using another Google API that is hitting such concurrency limitation.

Layo
  • 677
  • 6
  • 16
  • 2
    Unfortunately this is not the reason. These are random errors with wrong messages. There are no solutions for these unless Google fixes its own code. – Allen King May 29 '16 at 17:22
1

The referer header is not set by default, but it is possible to add the headers to a request like so:

$result = $t->translate('Hola Mundo', [
    'restOptions' => [
        'headers' => [
            'referer' => 'https://your-uri.com'
        ]
    ]
]);

If it makes more sense for you to set the referer at the client level (so all requests flowing through the client receive the header), this is possible as well:

$client = new TranslateClient([
    'key' => 'my-api-key',
    'restOptions' => [
        'headers' => [
            'referer' => 'https://your-uri.com'
        ]
    ]
]);

This worked for me!

Reference

zurgeg
  • 510
  • 6
  • 18
Hamza Rashid
  • 1,329
  • 15
  • 22
1

In my case, this error was caused by my invalid payment information. Go to Billing area and make sure everything is ok.

  • Thank you, yes due to Rs 0.33 overdue, I got this error, after successful payment done, then its working great – PNR Nov 06 '21 at 08:07
0

After hours of wondering around in Google Cloud settings, I found that is was the invalid payment information, as Federico Schiocchet mentioned, make sure your billing information is correct.

MJ Rezai
  • 1
  • 1
  • 2