Anwesh Mohapatra
Anwesh Mohapatra

Reputation: 194

How to see per user quota limit for gmail api?

We are using gmail api to parse latest mails for a few email ids. After few hours of running, we always encounter:

{
 "code" : 429,
 "errors" : [ {
   "domain" : "global",
   "message" : "User-rate limit exceeded.  Retry after 2020-08-25T05:11:14.899Z",
   "reason" : "rateLimitExceeded"
 } ],
 "message" : "User-rate limit exceeded.  Retry after 2020-08-25T05:11:14.899Z",
 "status" : "RESOURCE_EXHAUSTED"
}

I want to see user rate limit data but the gmail api metrics only show us our app metrics.
I have the email id credentials also with me. Is there any place we can check to exactly pinpoint how much of a surge is causing 429 error? From our app, we are sending about 3 requests/second (message.get, message.list, message.attachment.get, message.modify) as seen from the api metrics we have with us. The per user quota limit is 15000/minute or 250/second and we don't seem to be hitting no where near the limit. Based on this, we can only conclude that the email id has given oauth tokens to multiple apps who are hitting it relentlessly to cross the limit. Now only if we could see why it is happening and adjust our hit rate accordingly to minimize any chance of 429.
Also, if this is not possible then please suggest us a good hit rate/second so that 429 never happens.

Upvotes: 0

Views: 2640

Answers (1)

ziganotschka
ziganotschka

Reputation: 26796

429 error User-rate limit exceeded with returned with a time to retry mostly means you are hitting the Mail sending limits

Those limits are featured here:

Messages per day: 2,000 (500 for trial accounts)

Messages auto-forwarded: 10,000

Auto-forward mail filters: 20

Recipients per message: 2,000 total per message (maximum of 500 external recipients)

Recipients per message sent via SMTP (by POP or IMAP users) or the Gmail API: 100

Total recipients per day: 3,000 (2,000 external, 500 external for trial accounts) 5 emails sent to 10 different addresses count as 10 unique recipients* 5 emails sent to a single address count as 1 unique recipient*

Those limits are not related to the request rate per minute / second, but to the daily sending limits. Mind that if you have a trial user, your limits might be well below the ones for paying users.

Both your daily and minute based queries can be verified when you go in your GCP console on Gmail API -> Quotas - and select the relevant type from the dropdown.

If it shows that you are below the limit or you are not sure which limits you are hitting, you have the option to contact GSuite support for assistance.

Upvotes: 1

Related Questions