Number of Requests for Sheets API using Google Apps Script
This is a report for checking the number of requests for Sheets API. I had contact about the quota for Sheets API. So, in order to explain this, I used the following simple sample scripts.
Sample 1
This sample puts a value of “sample” to a cell “A1” using the batchUpdate method. This request body includes one request. When this script is run, one API quota is used.
function sample1() {
const spreadsheetId = "###";
const sheetId = 0;
const requests = [{
"updateCells": {
"rows": [
{
"values": [
{
"userEnteredValue": {
"stringValue": "sample"
}
}
]
}
],
"range": {
"sheetId",
"startRowIndex": 0,
"endRowIndex": 1,
"startColumnIndex": 0,
"endColumnIndex": 1
},
"fields": "userEnteredValue.stringValue"
}
}];
Sheets.Spreadsheets.batchUpdate({ requests }, spreadsheetId);
}
Sample 2
This sample puts 1000 values like “sample#” to the cells of “B1:B1000” using the batchUpdate method. This request body includes 1000 requests. When this script is run, one API quota is used.