let offset = 'A2';
let limit = 'Z999';
const sheetid = "<sheetid>";
const apikey = "<api key>";
const sheetname = "Sheet1";
const url = `https://sheets.googleapis.com/v4/spreadsheets/${sheetid}/values/${sheetname}!${offset}:${limit}?key=${apikey}`;
var sheet_data = [];
fetch(url).then(data => data.json()).then(data => {
sheet_data = data.values;
console.table(sheet_data);
});
- https://docs.google.com/spreadsheets/d/sheetid/edit?usp=sharing
- create/get apikey from https://console.developers.google.com/apis/credentials
- in https://console.developers.google.com
Go to > Libraries > Google Sheets > Enable
Sample Google Sheet Data

To get sheet id
Click on share then copy link

Create API Key

Final Output in HTML

Hi, I’m not the most familiar with backend and I have the following question.
Assuming this code is run on a server (Node.js server), does it mean the code will be run everytime a change is made to the sheets file? Can an implementation be made so that a button in Sheets can be pressed to run the code?
Thank you
Truman