I have a Google Colab Workbook that does some scrapping and saves the scrapped files in my Google Drive and I also have a Google App Script that manipulates these files in Google Spreadsheet.
Is there a way to trigger this Google App Script directly from Google Colab? So at the end of my scrapping it does all the things I need it to do, without the need to open Google Apps Script.
I know I could write code in Google Colab that does exactly what the Google App Script does. But I would like to avoid that.
You might use Google Apps Script to create a web-app or you might use the Google Apps Script API then call them from Google Colaboratory by doing a HTTP request. The method to be called to execute a Google Apps Script function is script.run.
Related
python requests POST with header and parameters
How to make a Post request to an API using Google Colab
Resources
https://developers.google.com/apps-script/api/quickstart/python
https://developers.google.com/apps-script/api/how-tos/execute#python
Related
I noticed that the Google Apps Script editor uses a Bearer token to make requests for a lot of things, that got me thinking: Is it possible to do all functions that are done with the google apps script with the google API on your own server? What is the essential difference? Just the fact that google apps script runs on google servers, while with the google API you would need to create your own servers?
For example many of the document functions, which I thought could only be done with the API, turns out can be found here https://developers.google.com/docs/api/reference/rest/v1/documents/request#InsertInlineImageRequest
so whats the essential difference?
Just the fact that google apps script runs on google servers, while with the google API you would need to create your own servers?
Yes. There are advantages to both methods:
API:
It's a rest API. You can use your own language(eg: Python) in your servers.
The api is more inclusive. There are stuff which can be done with the api, which cannot be accomplished with apps script.
User can set limited scopes for using API.
For example, at Drive API, https://www.googleapis.com/auth/drive.file can be used for Drive API. The same cannot be done with DriveApp of apps script.
Process cost of API is lower than that of the built-in methods for Google Apps Script1 2
Apps script:
No server on your side
Triggers. You can set up functions to run onEdit,onOpen or at a specific time.
Deep integration with Google apps: Sidebars/modal dialogs can only be done with apps script.
All methods of the api can be accessed indirectly through the bearer token.
Authorization/authentication is taken care of by apps script. You don't need to set up oauth.
Is there a way to run a google app script from a different app script?
im just getting into google app scripts and i couldnt find anything on the internet
It seems like you are looking for libraries functionality in Google App Script. Documentation
You can save a version of the script that you have the functions in it, and import the functions on to a second script file through menu>resources>libraries. You need to use script id for importing libraries, which you can find from menu>File>Project properties>Script ID
You can then execute the function using the script file name as the reference.
You can use the Apps Script API, you may find this helpful Executing Functions using the Apps Script API
"The Apps Script API provides a scripts.run method that remotely executes a specified Apps Script function"
You can call google app script form javascript or web page.
You have to implement doGet(or post) and publish your google app script.
I found good example.
Cheers.
I have an app-maker server-side script that I would like to be able to call from the client script, or from code in a Google Sheet. Is this possible? If not, what would be the best way to create code that can be called from an app maker client or a google sheet?
I have been looking for a way to interact with my google sheets (and other services) from Excel (and other desktop applications).
For example:
I get a report from a work system and my boss asks me to update the information in the google sheets so that our site is up to date with the latest information.
What would be great (and easy for me) would be to use a VBA script in my spreadsheet to turn all my data in http requests and then do the heavy lifting with Google Apps Script in the cloud and finally updating the Google Sheets with the associated API.
When I look at the oAuth2 playground I can't find a way to enable Google Apps script, as I have successfully done so with other APIs.
(to be clear, I don't want to do oAuth2 with in GAS - which is a lot of the other questions that get raised)
Is this a hard problem or is there a solution?
There is currently no way of calling a Google Apps Script from an external program. You do have a few other options:
Import the relevant data into Google Sheets manually and use Google Apps Script to process it as needed, possibly making use of time-based triggers to handle the processing automatically.
Use the Google Spreadsheets API. Unlike Apps Script, this API is built to be called from other programs and can manipulate Google Sheets. However, it is a bit more difficult to use than Apps Script. Once data has been moved into a Google Sheet, a separate Apps Script can be used to manipulate it.
I want to build a Google Doc Extension.
Google Spreadsheets has an onEdit trigger, Google Documents don't seem to: https://developers.google.com/apps-script/understanding_triggers
Is there a way for me to handle user input (typing) cleanly?
Not in Apps Script. If you write an app using the Drive API, you can use the Realtime API https://developers.google.com/drive/realtime/