Reputation: 329
I'm using the module google-spreadsheet (NPM) for NodeJS, but i've a questions: How can i check how many requests i've and how can i handle the usage limit reach?
I'm trying with this code to try it:
try {
for (let i = 0; i <= 305; i++) {
await sheet.getRows(mySHeet);
console.log("test: " + (i + 1));
}
} catch (err) {
console.log("Error:", err)
}
But after 300 requests (the limit is 300 per minute) the app simply crashes with error code 1 without giving anything and it does not enter in the catch.
So if the APP reach the Google API limits, it crashes and exit. I've also handled the errors with process but it doesn't change anything: (with unhandledRejection and uncaughtException).
Thank you!
Upvotes: 0
Views: 254
Reputation: 26836
While I do not work with NPM,
I can advice you to review the Google Sheets API Usage Limits.
As you see,
Sheets API Usage Limits are 100 requests per 100 seconds per user.
Temporary bursts are allowed (this is why you might get away with 300 requests per minute), but you are stretching it.
Upvotes: 1