4
votes

I have a Google Sheet and I want to have its data updated from our server. Currently I'm using google sheet script editor. google sheet->tools->script editor https://developers.google.com/apps-script/guides/sheets

But I came to realize that there is another way to have my google sheet updated. And thats using google sheet api https://developers.google.com/sheets/api/samples/writing https://developers.google.com/sheets/api/reference/rest/ https://developers.google.com/sheets/api/samples/

So I would liked to know what are the differences. And find out what best suits for my case.

1
In most cases, Google-Apps-Script works faster for same tasks. Use API for special purposes only, when Apps-Script can't do smth API can.Max Makhrov
Using Api, you can use the language of your choice-like python, java,C,nodejs,etc.TheMaster
If you request reduced permissions from your users, you often need to use the REST API / client library instead of Apps Script native classes, due to the lack of scope awareness in them. So if you have only drive.metadata.readonly scope, DriveApp methods will generally throw an exception due to lack of permissions to access the underlying files (even if you just use metadata fields like name and mimetype in your code).tehhowch
There are the situations that only Sheet API can do and SpreadsheetApp cannot do. For example, 3 situations of several sample situations are as follows. Situation 1, Situation 2 and Situation 3Tanaike

1 Answers

7
votes

Summary: If you are beginning to work with Sheets programmatically, use Google Apps Script.

Google Apps Script is an extension of (an old version of) JavaScript. It is executed on Google servers and has direct access to spreadsheets and other documents to which the owner account has access. It can also interact with the code on your company's server by handling GET and POST requests (doGet and doPost functions) and sending them (UrlFetchApp methods).

Google Sheets API is not tied to any language; it's just a collection of requests that can be sent to Google servers by whatever code in whatever language. So, the code on your company servers can send some GET or POST requests to Google following the API structure, in order to access or change the data in your sheets.

Google Apps Script can access Sheets API using an Advanced Service:

Much like Apps Script's built-in Sheets service, this API allows scripts to read, edit, format and present data in Google Sheets. In most cases, the built-in service is easier to use, but this advanced service provides a few extra features.