Search code examples
google-calendar-api

Is there any way to know the waitTime if Google calendar usageLimit or rateLimit is reached


I am working on developing integration with Google Calendar using Rest API. I got to know Google applies both rateLimit and usageLimit on API calls - 403_calendar_usage_limits_exceeded

In case I breach the limits, I want to wait for a defined period of time before I retry the request again. Is there any way to know if there is something like Retry-After header returned by Google.

I checked documentation but not able to find anything related - errors


Solution

  • You can see your quota in google developer console under libary search for google calendar and then click the manage button. Under the quota tab you will see something like this.

    enter image description here

    There are two types of quota user based quota denoted by the "per user" and project based quotas.

    Each user running my application can make a max of 600 requests per minute. if they make to many then i will get a quota exception.

    My application can make a max of 10000 request per minute in total. if it makes more then that then again i will get a quota exception.

    You may want to read though Manage quotas this explains a lot about quota usage and the google calendar api.

    For the most part if you just implement exponential backoff you should be able to avoid to many of these errors.

    1. try request if fails
    2. wait 10 seconds
    3. try again if fails
    4. wait 20 seconds
    5. try again if fails
    6. wait 30 seconds
    7. try again .......