Skip to content
Create a REST API backed by Google Sheets
Branch: master
Clone or download

Latest commit

Latest commit 52aed03 Jun 5, 2017


Type Name Latest commit message Commit time
Failed to load latest commit information.

Create an API backed by Google Sheets

Use this repo to create a quick-and-dirty API that will store data in Google Sheets.


First clone and install

git clone && cd sheets-api
npm install
npm install -g datafire


Use datafire authenticate to add your credentials. See below for instructions on getting your Google Sheets credentials

datafire authenticate google_sheets --alias sheetsOwner

Create a new sheet

You can manually create a new sheet at, or run this command, replacing "Pet Store" with your title

datafire run google_sheets/spreadsheets.create \ "Pet Store" \
  --accounts.google_sheets sheetsOwner

# spreadsheetId: abcd
# properties:
#   title: Pet Store
# ...

Copy spreadsheetId from the response (or the URL) and paste it into spreadsheet.js: = "abcd";


Start the server with datafire serve:

datafire serve --port 3000 &

View pets

# Get the first 10 results
curl http://localhost:3000/pets

# Get the second page
curl http://localhost:3000/pets?page=2

# Get pet #12
curl http://localhost:3000/pets/12

Add a pet

curl -X POST -d '{"name": "Lucy", "age": 2}' \

Stop the server

kill $!

Modify the API

The field names and validation info are all in spreadsheet.js. You can modify that file to change the API.

You can also change the URL from /pets to something new by editing DataFire.yml.

Creating a Google Sheets client

To register a Google Sheets client, visit

  • click "Enable API"
  • click "Credentials"
  • click "Create Credentials" -> "OAuth Client ID"
  • Choose "web application"
  • add http://localhost:3000 as an "Authorized redirect URI"
You can’t perform that action at this time.