Setup

After following this page you will have a free, fully-featured and secure spreadsheet API at your disposal.

Prerequisites

The first row in each spreadsheet is treated as column names. E.g. let's take the following spreadsheet:

The API for getting all rows would return the following result:

Installation

In your spreadsheet open Extensions -> Apps Script.

Copy the below script to the Google Script Editor and save it.

You can find a non-minified version of the above script at https://github.com/ziolko/spreadapi.

Authentication

SpreadAPI uses a custom authentication mechanism. Directly in the script, you can define multiple Users with granular access levels. Each user has an access key used to authenticate him while accessing the API.

Access key

The access key should meet the following criteria:

  • be at least 8 characters long

  • contain at least one lower case (e.g. a, b, c)

  • contain at least one upper case (e.g. A, B, C)

  • contain at least one number (e.g. 1, 2, 3)

  • contain at least one special character (e.g. #, ^ )

If you don't want to meet these criteria or need to leave the access key empty (e.g. to allow anonymous access) you can mark the password as UNSAFE as shown in the example below:

Scopes

Access can be granted for each sheet and operation (GET, POST, PUT and DELETE) separately. E.g. the following configuration allows anonymous user to add entries (but not read, delete or modify) to a sheet called transactions and read (but not add, modify or delete) from a sheet called summary.

You can allow more than one operation for a single sheet using the array syntax or all of them with an alias ALL.

Deployment

Once you have authentication configured you can deploy the API. To do that click Deploy -> New deployment

On the New deployment popup select type Web app and choose the following options:

  • Execute as: Me,

  • Who has access: Anyone

After clicking deploy you will be asked to grant the script authorization to your spreadsheet.

Note: You grant read/write access to your spreadsheet to the script you've just created. You don't grant access to your data to any third-party (not even to SpreadAPI author).

That's it!

After successfully deploying the script you should get its URL. You will use this URL to make requests to the spreadsheet API. See usage for details.

Last updated