Use Google Sheets as Database/API

Saroj Subedi
Sep 3, 2018 · 2 min read

We will be making a fully working API that can be used to get data out of a Google Spreadsheet without any coding. It will take you ~5 minutes, and you will not need to code anything.

  1. Create a Google Spreadsheet
  2. Populate your data just like in below image as any structured data you want.
Populating the data in Google Sheets

3. Then Click : File option from top bar , then click Publish to web : and you will see this dialog box , click Publish Button as shown in below image.

Now, you are ready to use your sheet as database.Copy your sheet document id (DOCUMENT_ID) which you will get from URL (your google sheet URL) like this:

https://docs.google.com/spreadsheets/d/2nQ6aZvFzOpdPx6uSqWgFVGtnO_G9oiPhWzRHUCQlBU

Then use this API endpoint https://exceldb.herokuapp.com/r/ which I have already developed for pulling data from Google Sheets.

Api Endpoint:

https://exceldb.herokuapp.com/r/DOCUMENT_ID

Note: DOCUMENT_ID is the id of the google sheet which I have already mentioned above.

Check below image where data is pulled from this link.

https://excel-db.herokuapp.com/r/1QnQ6HZvFzOpFPx5uSqWgDVGtnO_G9oiPhWzRHUCQlBU

**New Feature**

Make query in Google spreadsheet by Post Request.

Example :

curl -X POST \
https://excel-db.herokuapp.com/r/1QnQ6HZvFzOpFPx5uSqWgDVGtnO_G9oiPhWzRHUCQlBU \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Postman-Token: e1d8a0e2-7282-42bb-8759-69a11b2e9264' \
-H 'cache-control: no-cache' \
-d 'id=1'

Here we are pulling only data which have id = 1.

Output:

[
{
"id": "1",
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\\nsuscipit recusandae consequuntur expedita et cum\\nreprehenderit molestiae ut ut quas totam\\nnostrum rerum est autem sunt rem eveniet architecto"
}
]

Saroj Subedi

Written by

Software Engineer at Bookmundi APS

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade