Web api with Google Sheet + AppScript
Google Sheets — AppScript
With Google spreadsheets we can perform operations such as Insert / Update / Delete / Read using Google AppScript . And it can be used as our backend.
Google spreadsheet settings:
- Login to your Google account
- Create a new spreadsheet CLICK_ HERE .
- When you create a spreadsheet you will see the id in the url as highlighted in the following image
Copy the url of your google sheet.
As above, you can see that I have highlighted part of the url. You can copy the shared url as you realize or just the url .
4. As in the image below, go to Tools → Script Editor.
Google AppScript Settings:
- Then you will see the following screen.
Here in this editor , we have to write the code that act as a web API and will intereact GoogleSheets.
2. Below is the AppScript that you should write to the above file and save it.
3. Select from tab, Publish → Deploy as web app
4. You will see a window like this, just make sure to select ‘Run the application’ as ‘Me’ and ‘Who has access to the application’ as ‘Anyone, even anonymous’. Every time you perform an update you must choose a new one
Authorization is required. Just check the permissions. Then select your Google account.
You will see a screen, just expand ‘Advanced’ and click on ‘Go to YOUR_PROJECT_NAME (insecure)’.
Allow these permissions and voila!
Finally, you will get a window like this with the URL of the web application. Copy that web url for reference. We will use this URL to make HTTP GET requests.
Copy the url plus the function that we declare:
WEB_APP_URL_SCRIPT / exec? Action = getItems
URLs:
1. Web Api: https://script.google.com/macros/s/AKfycby01lKNm94FHYORH3_c-lHK35r4zOoZiF8_tOD-QhfujBcglDiE
2. Example Published :