Using Google sheets as an API For your next app

Using Google sheets as an API For your next app

Featured on Hashnode

Yup, you can use google sheets as an API for your next app .. yes it is possible. Google already provides an API that you can use to read and write data in google sheets also there is an npm package to do the same. so you can basically do all basic function in google sheets.

But this post is not about that..

via GIPHY

This blog is about a trick which I recently discovered, It makes work a lot easy if you just need to display data from google sheet in your App. Imagine a scenario in which you need to display data from a google sheet list of students, list of all important Contract numbers in case of emergency. or something like that If you only need to display data and you are in a hurry.

Firstly go to a google sheet and publish the web.

ezgif.com-gif-maker (1).gif

once it is done now take a look at the URL of your google sheet.

Screenshot from 2021-01-24 17-59-03.png now just copy this unique URL and

https://spreadsheets.google.com/feeds/worksheets/{Unique URL }/public/basic?alt=json

now just hit this URL in your browser or in postman. now look a the response of the API.. just search for the entry array in the link object.. here you will find the various link to your google sheet .. but they will arrange data in a different format.. one will give you data in a list format and another will just throw data in a cell wise format. just go with format you are comfortable with.

Screenshot from 2021-01-24 18-19-53.png

but if you hit that URL directly it will not give you data in the desired format. just remember to add a query argument (alt=json)

you can take this URL as an example

https://spreadsheets.google.com/feeds/list/1cXItNrEtnHRBIAo612LImhjnsFMSbgli-R94T2SPhHE/od6/public/basic?alt=json

Screenshot from 2021-01-24 18-29-36.png

just remember to add ?alt=json at the last of the URL. Hope you like my articles if I can improve my writing more please let me know in the comment section. Also do react and share if it helped you.

Did you find this article valuable?

Support Gaurav Tewari by becoming a sponsor. Any amount is appreciated!