Welcome

Hello!

SheetKit is being built to be easy to use and to make your once-static websites come alive with server-side functionality.

To get started with SheetKit, you'll need to go through our checkout process. Once we fulfill your order, just open your Google spreadsheet. From inside you'll get your API key, enabling our JavaScript API as is detailed here. Please don't hesitate to contact us if we can help in any way!

SheetKit is in development and not quite ready.


Colin Mathews
Creator of SheetKit
@colinmathews

Getting Started

Place this script on your page and enter your API key.

<script data-sheetkit-key="[YOUR KEY]" src="//d209ue3xilo57p.cloudfront.net/1.0.0/sheetkit.js"></script>

Wrap all of your code in a call to SheetKit.ready.

SheetKit.ready(function(err){
	if (err)
		return alert("Something's not quite right.");

	// SheetKit is ready!
});

How Operations Work

All operations are asynchronous and take two parameters: an object of options and a callback function. An optional third scope parameter can be passed so that this refers to an object of your choice.

Each callback function take two arguments: an error object if something went wrong and a result.

Parameters

options:
required object

A list of key-value options.

callbackFn:
required function

The callback function to invoke when the operation completes taking error and result.

scope:
optional object

The context to use for this in the callback function.

service.operationName({
	option1 : 'value'
}, function(err, result){
	// Handle failure or success
}, this);

Data Types

Most raw values can be specified as native JavaScript types such as 'John Doe', 5, true, and new Date(). You can store JSON strings in your spreadsheet by passing an object in your operations. This could be useful, for instance, in storing variable user settings in a single spreadsheet column.

db.add({
	sheet : 'Sheet1',
	data : {
		Text : 'Text value',
		Numeric : 64,
		Boolean : true,
		Date : new Date(),
		Json : {
			field1 : 'value1'
		},

		// Here are the special types
		Password : {
			type : 'password',
			value : 'thisismypassword'
		},
		Guid : {
			type : 'guid',
			value : ''
		}
	}
}, function(err, result){
	// Handle failure or success
}, this);

How your spreadsheet will look

id Text Numeric Boolean Date Json Password Guid created updated
a95bfc6e-1b6d-eb2e-bc5c-df7613d81f27 Text value 64 TRUE 1/14/2015 2:31 PM {"field1":"value1"} {"type":"password","value":"du2uGj..uM="} e3bad449-ac29-dd6a-d170-03cd00efe2fe 1/14/2015 2:31 PM 1/14/2015 2:31 PM

Here are the special types you can use:

Types

password:

Creates a SHA-256 HMAC of the value so that it remains encrypted. Exact matching can be done on these fields. When rows with this type are queried, this field is omitted from the response.

guid:

Creates a unique, unguessable value.

Automatic Fields

Every sheet in your spreadsheet will automatically get and track the following fields:

Fields

id:

A non-guessable id to uniquely identify a row.

created:

The date when this row was created.

updated:

The date when this row was last updated.

How an empty sheet will look

id created updated
a95bfc6e-1b6d-eb2e-bc5c-df7613d81f27 1/14/2015 2:31 PM 1/14/2015 2:31 PM

Configuration

Inside your spreadsheet you'll see a way to store a JSON-formatted configuration. This stores security information, secret values, and other details to make your sheet run just the way you need it to. Without a configuration, you'll get smart defaults: you'll be able to add rows, update them if you know their id, and run searches.

Here's a sample configuration that shows most of our features:

{

	// Random characters used to securely store passwords.
	// Changing this value will corrupt all password data in your spreadsheet.
	"sheetKitSecret" : "somerandomcharactersandsymbols",

	// Store the recaptcha secret for each website you use SheetKit on
	"recaptcha" : {
		"www.mywebsite.com" : {
			"secret" : "abcdefghijklmnop"
		}
	},

	// Info needed to integrate with Stripe
	"stripe" : {
		"live" : {
			"publishableKey" : "pk_live_VM123456",
			"secret" : "sk_live_7qabcdefgh"
		},
		"test" : {
			"publishableKey" : "pk_test_pU4098765",
			"secret" : "sk_test_jzSzxywvtabcdef"
		}
	},

	// Info needed to send notifications
	"notify" : {
		"contactus" : {
			"from" : "myteam@mycompany.com",
			"to" : "support@mycompany.com",
			"requireCaptcha" : false
		}
	},

	"security" : {

		// Pages that know this key can bypass all security
		"godModeKeys" : ["thisisasecretkey"],

		// Database security is implemented on a per-sheet basis
		"sheets" : {

			// Require captcha on this sheet when creating new rows.
			// Only allow searching if an exact email and password combination is specified.
			"Users" : {
				"find" : ["Email Address", "Password"],
				"recaptcha" : {
					"add" : true
				}
			},

			// Support for sheets with multiple words
			"Multi Word Sheet Name" : {

				// Allow searching, but rows won't be able to be modified 
				// because they'll be missing their id fields
				"find" : "readonly"
			},

			// This sheet will not allow the "Color" column to be updated
			"Favorite Colors" : {
				"add" : false,
				"readonly" : ["Color"]
			},

			// This sheet will be inaccessible to the API
			"Movies" : {
				"add" : false,
				"updateOne" : false,
				"find" : false
			}
		},

		// Specify security for the SheetKit.Remote class
		"remote" : {

			// To disable this class altogther, just flip this setting
			"enabled" : false,

			// Restrict what urls can be accessed (case insensitive)
			"urlsMustStartWith" : ["https://somedomain.com/api", "https://someotherdomain.com/api"],

			// A collection of configurations to alter how requests are made
			"config" : {

				// Specifies how requests to MyFavoriteCloudService should be altered
				"MyFavoriteCloudService" : {

					// These values will be forced onto the HTTP request
					"data" : {
						"apiKey" : "abcdefghijklmnop"
					}
				},

				// Another one
				"Service2" : {

					// Pass headers
					"headers" : {
						"Authorization" : "Basic ZnJlZDpmcmVk"
					}
				}
			}
		}
	}
}

SheetKit.DB Security

SheetKit was made to help you get up and running with supreme quickness. This convenience means a smart person could use your SheetKit API from their browser and programmatically add rows to your spreadsheet. For many use cases this isn't really a serious problem, but if you get to a point where it is, you're hopefully getting enough traction to outgrow SheetKit (hooray!). That being said, SheetKit has several security settings to help prevent abuse.

You can configure each sheet in your spreadsheet to have various levels of security. For each spreadsheet, these are the settings you can enable:

Properties

add:
boolean

true to allow adding to this sheet. Defaults to true.

updateOne:
boolean

true to allow rows to be updated on this sheet by their unique ID. Defaults to true.

updateMany:
boolean array

true to allow multiple rows to be updated on this sheet by a query. Defaults to false.

For increased security, you can allow mass updates, but require exact matches on the fields queried so that end-users can only update certain rows. For instance, to update a "User" by their email address and password, use ["Email address", "Password"].

find:
boolean string array

true to allow searching. Defaults to "readonly".

Set to "readonly" to allow searching, but to not return row ids so they cannot be subsequently updated.

For increased security, you can allow searching but require exact matching on specific fields. For instance, to look "Users" up by their email address and password, use ["Email address", "Password"].

removeOne:
boolean

true to allow single rows to be removed from this sheet by their ids. Defaults to false.

removeMany:
boolean array

true to allow multiple rows to be removed from this sheet by a query. Defaults to false.

For increased security, you can allow mass removes, but require exact matches on the fields queried so that end-users can only update certain rows. For instance, to remove a "User" by their email address and password, use ["Email address", "Password"].

readonly:
array

A list of fields (in addition to automatic fields) that cannot be modified by updates.

Here's a sample configuration to make a sheet named "Movies" read-only.

{
	"security" : {
		"sheets" : {
			"Movies" : {
				"add" : false,
				"updateOne" : false
			}
		}
	}
}

Here's a sample configuration to allow searching without returning row ids. Unique ids must be known to update or remove rows.

{
	"security" : {
		"sheets" : {
			"Movies" : {
				"find" : 'readonly'
			}
		}
	}
}

Here's a sample to make a sheet named "Users" only searchable by an exact email address and password combination.

{
	"security" : {
		"sheets" : {
			"Users" : {
				"find" : ["Email address", "Password"]
			}
		}
	}
}

Here's a sample to make a sheet named "Users" only updatable and removable by an exact email address and password combination (or their unique row id).

{
	"security" : {
		"sheets" : {
			"Users" : {
				"find" : ["Email address", "Password"],
				"updateMany" : ["Email address", "Password"],
				"removeMany" : ["Email address", "Password"]
			}
		}
	}
}

Requiring reCAPTCHA

In some cases you may want to allow operations, but help prevent programmatic abuse. You can set each operation to require a reCAPTCHA value from Google's free reCAPTCHA service.

First, you need to store your secret from Google so we can validate your requests. You will have a different secret for each website you use SheetKit on, so each secret is tied to the domain used.

{
	"recaptcha" : {
		"www.mywebsite.com" : {
			"secret" : "abcdefghijklmnop"
		},
		"www.myotherwebsite.com" : {
			"secret" : "zyxwfsdfkerusdfk"
		}
	}
}

Then, in your security settings for each sheet you can require reCAPTCHA values for various operations.

Properties

add:
boolean

true to require a reCAPTCHA value for add operations to be allowed.

updateOne:
boolean

true to require a reCAPTCHA value for updateOne operations to be allowed.

updateMany:
boolean

true to require a reCAPTCHA value for updateMany operations to be allowed.

find:
boolean

true to require a reCAPTCHA value for find operations to be allowed.

removeOne:
boolean

true to require a reCAPTCHA value for removeOne operations to be allowed.

removeMany:
boolean

true to require a reCAPTCHA value for removeMany operations to be allowed.

Here's a sample configuration to make a sheet named "Users" require reCAPTCHA values to create new rows and to disable searching. This is a great way to represent users in your database.

{
	"security" : {
		"sheets" : {
			"Users" : {
				"add" : true,
				"find" : false,
				"requireCaptcha" : {
					"add" : true
				}
			}
		}
	}
}

And here's a sample add call against this sheet. The recaptcha value should come from Google's JavaScript reCAPTCHA service.

SheetKit.DB.add({
	sheet : 'Users',
	recaptcha : '...',
	data : {
		Username : 'user101',
		Password : {
			type : 'password',
			value : 'thisismypassword'
		}
	}
}, function(err, row){
	// Handle success or failure
});

Here's a really cool example. Using SheetKit's parsing, you can let SheetKit automatically plug in the user's recaptcha response.

<script src='https://www.google.com/recaptcha/api.js'></script>
<div id="add-user">
	<input type="text" name="Username">
	<input type="password" name="Password">
	<div class="g-recaptcha" data-sitekey="[YOUR RECAPTCHA CLIENT KEY]"></div>
</div>
SheetKit.DB.add({
	sheet : 'Users',
	data : document.getElementById('add-user')
}, function(err, row){
	// Handle success or failure
});

God Mode

In some cases you may want a secret page that can perform all operations despite your security settings. Good examples include an admin panel for your site, a development-only website, or a personal site that won't be exposed to too many people.

In your security configuration, you can specify a list of "God mode" secret keys that if used, will bypass your security. Then your calling code just needs to send one of these keys for each operation.

Here's a sample configuration with a single God mode key that normally disallows all operations on the "Users" spreadsheet.

{
	"security" : {
		"godModeKeys" : ["thisisasecretkey"],
		"sheets" : {
			"Users" : {
				"add" : false,
				"find" : false,
				"updateOne" : false
			}
		}
	}
}

And here's a sample find call against this sheet to list all rows.

db.find({
	godMode : 'thisisasecretkey',
	sheet : 'Users'
}, function(err, rows){

	// All rows returned, even if find is not allowed
});

Payments

SheetKit can process payments via your Stripe account. Enable this capability by storing settings for live and/or test modes.

{
	"stripe" : {
		"live" : {
			"publishableKey" : "pk_live_VM123456",
			"secret" : "sk_live_7qabcdefgh"
		},
		"test" : {
			"publishableKey" : "pk_test_pU4098765",
			"secret" : "sk_test_jzSzxywvtabcdef"
		}
	}
}

SheetKit.Remote Security

SheetKit.Remote executes HTTP requests. You can configure security to enforce limitations and to alter requests as they are sent.

Properties

enabled:
boolean

false to disallow this service. Defaults to true.

urlsMustStartWith:
array

An array of url fragments that any executed request must start with (case ignored). If this is omitted or blank, any url will be allowed.

config:
object

A series of configuration objects for named services. Each key is the name of the configuration and can be anything you like. The key is passed in for the configuration parameter to SheetKit.Remote.send.

Each configuration object can look like this:

Properties

data:
object

A list of key-value pairs that will be added to any outgoing HTTP request. Use this to specify secret API keys.

headers:
object

A list of key-value pairs that will be added as headers to any outgoing HTTP request. Use this to specify API authentication or to configure how the service should respond.

Here's a sample way to configure a service with the user-defined key of "MyFavoriteCloudService":

{
	"security" : {
		"remote" : {
			"config" : {
				"MyFavoriteCloudService" : {
					"data" : {
						"apiKey" : "abcdefghijklmnop"
					},
					"headers" : {
						"Authorization" : "Basic ZnJlZDpmcmVk"
					}
				}
			}
		}
	}
}

And here's how you use this configuration:

var remote = new SheetKit.Remote();
remote.send({
	url : '...',
	configuration : 'MyFavoriteCloudService'
}, function(err, result){
	// Handle failure or success
});

SheetKit.Notify Security

SheetKit.Notify allows you to send email notifications. In order to use this feature you must open your SheetKit spreadsheet and click the "Authorize Email Account" menu item.

Properties for "contactus" group

from:
required string

The from address to send "contact us" emails from. When you go through your SheetKit spreadsheet's authorization menu item, this value will be defaulted to the Google account you authenticate with.

to:
optional string

Who to send "contact us" emails to in your organization. When you go through your SheetKit spreadsheet's authorization menu item, this value will be defaulted to the Google account you authenticate with.

enabled:
boolean

false to disallow "contact us" emails. Defaults to true.

requireCaptcha:
boolean

true to require the user pass Google's Recaptcha test. Defaults to false.

Here's a sample configuration:

{
	"notify" : {
		"contactus" : {
			"from" : "myteam@mycompany.com",
			"to" : "support@mycompany.com"
		}
	}
}

SheetKit.SheetKit

The entry point of the API.

SheetKit.ready

Sets up the page for working with SheetKit. All of your code should be wrapped inside a call to this method.

Result

None.

SheetKit.ready(function(err){
	if (err)
		return alert("Something's not quite right.");

	// SheetKit is ready!
});

SheetKit.Error

Represents any error reported by the SheetKit framework. You can detect this error using instanceof.

Properties

message:
string

A human-readable message indicating the problem.

isFriendly:
boolean

True if this message can be displayed directly to end users.

if (err instanceof SheetKit.Error)
{
	if (err.isFriendly)
		alert(err.message);
	else
		alert('Something went wrong!');
}

SheetKit.SheetKit.UI

Service to help with user interface interactions.

SheetKit.UI.parseForm

Reads an element and pulls out any form fields and translates them into a data object that can be used to create rows. Each form field with a "name" attribute will be read.

NOTE: Unlike most calls, this is a synchronous method call that accepts an HTMLElement and returns an object.

Parameters

el:
required HTMLElement string

An HTMLElement to read data from.

You can alternatively specify a CSS selector like: "#my-forms .form-1"

Result

A data object representing the form fields.

<div id="add-user">
	<input type="text" name="Username">
	<textarea name="Bio"></textarea>
	<input type="password" name="Password">
	<input type="checkbox" name="IsAdmin">
	<select name="FavoriteColor">
		<option>Blue</option>
		<option>Red</option>
		<option>Green</option>
	</select>
</div>
var data = SheetKit.UI.parseForm('#add-user');

// Parsed data looks like this
{
	Username : 'person101',
	Bio : 'My bio...',
	Password : {
		type : 'password',
		value : 'mypassword'
	},
	FavoriteColor : 'Blue'
}

SheetKit.SheetKit.Util

Provides miscellaneous utilities.

SheetKit.Util.isValidEmail

Determines if the text that's given is a well-formed email address.

NOTE: Unlike most methods, this method is synchronous and takes a string input.

Parameters

address:
required string

The text to examine.

Result

True/false if this text represents an email

if (!SheetKit.Util.isValidEmail('person@example.com'))
	alert('Please enter a valid email address');

SheetKit.DB

Properties

sheet:
string

You can optionally set this property if all of your operations on the database will be against a single spreadsheet sheet. This just saves you from entering it in each operation.

SheetKit.DB is a static class that lets you perform operations against your spreadsheet as if it were a database.

SheetKit.DB.add

Creates new rows of data. Data fields that don't match columns in your spreadsheet are ignored.

Options

sheet:
required string

The name of the sheet that houses this data in your spreadsheet.

data:
required array object HTMLElement

An object of data to save for this row. Each key should match a column name in your spreadsheet (wrap the column name in quotes if it contains spaces).

You can pass in an HTML element and all of the form fields will be parsed using their "name" attribute.

You can also pass an array objects to add multiple rows at once. If so, the result will be an array of rows instead of just a single row.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

godMode:
optional string

To bypass your security settings, enter a God mode key.

Result

A SheetKit.Row object representing the created row.

SheetKit.DB.add({
	sheet : 'Movies',
	data : {
		Title : 'What About Bob?',
		Year : 1991
	}
}, function(err, row){
	// Handle failure or success
});

Using HTMLElements

Pass in HTMLElements for the data parameter and SheetKit will parse form fields. Password fields are automatically converted to SheetKit password types.

<script src='https://www.google.com/recaptcha/api.js'></script>
<div id="add-user">
	<input type="text" name="Username">
	<input type="password" name="Password">
	<div class="g-recaptcha" data-sitekey="[YOUR RECAPTCHA CLIENT KEY]"></div>
</div>
SheetKit.DB.add({
	sheet : 'Users',
	data : document.getElementById('add-user')
}, function(err, row){
	// Handle success or failure
});

SheetKit.DB.find

Queries your spreadsheet to find matching rows. Queries are formed in a Mongo-esque style.

Options

sheet:
required string

The name of the sheet that houses the data in your spreadsheet to be searched.

query:
optional object

A query for finding rows that match certain characteristics.

ignoreCase:
optional boolean

False to enforce case-sensitivity in searching. By default this is true.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

godMode:
optional string

To bypass your security settings, enter a God mode key.

Result

An array of found SheetKit.Rows.

SheetKit.DB.find({
	sheet : 'Movies',
	query : {
		Year : {
			$gt : 1990
		}
	}
}, function(err, rows){
	// Handle failure or success
});

Queries

Specify an object mapping field names to values you want to match. Multiple fields can be specified and the query will ensure ALL fields match. Here's a simple query that only finds movies named "Ghostbusters" with a release year of 1991.

SheetKit.DB.find({
	sheet : 'Movies',
	query : {
		Title : 'Ghostbusters',
		Year : 1991
	}
}, function(err, rows){
	// Handle failure or success
});

Complex data types can be specified in the same way that they were created. For instance, here's a query to match on a password field (the spreadsheet will store a HMAC of the password).

SheetKit.DB.find({
	sheet : 'Users',
	query : {
		Username : 'myusername',
		Password : {
			type : 'password',
			password : 'thisismypassword'
		}
	}
}, function(err, rows){
	// Handle failure or success
});

Instead of simple matching, you can execute supported operators. For instance, here's a query to find movies that were released after 1990.

SheetKit.DB.find({
	sheet : 'Movies',
	query : {
		Year : {
			$gt : 1990
		}
	}
}, function(err, rows){
	// Handle failure or success
});

And of course, you can specify multiple operators and multiple fields. The query below finds all movies released between 1985 and 1995 that were directed by Frank Oz.

SheetKit.DB.find({
	sheet : 'Movies',
	query : {
		Year : {
			$gt : 1985,
			$lt : 1995
		},
		Director : 'Frank Oz'
	}
}, function(err, rows){
	// Handle failure or success
});

Query operators

$eq:

True if the field is an exact match to your value.

$ne:

True if the field is not an exact match to your value.

$gt:

True if the field is greater than your value.

$lt:

True if the field is less than your value.

$gte:

True if the field is greater than or equal to your value.

$lte:

True if the field is less than or equal to your value.

$startsWith:

True if the field is starts with your value. Mainly useful for basic string matching.

$endsWith:

True if the field is ends with your value. Mainly useful for basic string matching.

$contains:

True if the field is contains your value. Mainly useful for basic string matching.

$regex:

True if the field matches your regular expression. Mainly useful for complex string matching.

SheetKit.DB.get

Fetches a single row by its id value and returns null if the row does not exist.

Options

sheet:
required string

The name of the sheet that houses this data in your spreadsheet.

id:
required string

The unique ID of this row.

Result

A SheetKit.Row object if found, null otherwise.

SheetKit.DB.get({
	sheet : 'Movies',
	id : '...'
}, function(err, row){
	// Handle failure or success
});

SheetKit.DB.updateOne

Updates a single row by its id. You can also call update directly on SheetKit.Row objects.

Options

sheet:
required string

The name of the sheet that houses this data in your spreadsheet.

id:
required string

The unique id of the row you want to update.

data:
required object HTMLElement

An object of data to save for this row. Each key should match a column name in your spreadsheet (wrap the column name in quotes if it contains spaces).

You can pass in an HTML element and all of the form fields will be parsed using their "name" attribute.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

godMode:
optional string

To bypass your security settings, enter a God mode key.

Result

A SheetKit.Row object representing the updated row.

SheetKit.DB.updateOne({
	sheet : 'Movies',
	id : '...',
	data : {
		Director : 'Frank Oz'
	}
}, function(err, row){
	// Handle failure or success
});

All update operations can utilize these special operators:

Update operators

$inc:
number

Increments the value by the amount given.

Increment the votes for this movie.

SheetKit.DB.updateOne({
	sheet : 'Movies',
	id : '...',
	data : {
		$inc : {
			Votes : 1
		}
	}
}, function(err, row){
	// Handle failure or success
});

SheetKit.DB.updateMany

Updates multiple rows by a query similar to the find operation. By default this is disabled. Update your security configuration to allow this operation.

Options

sheet:
required string

The name of the sheet that houses this data in your spreadsheet.

query:
optional object

The query to find rows to update.

ignoreCase:
optional boolean

False to enforce case-sensitivity in searching. By default this is true.

data:
required object HTMLElement

An object of columns to update for the found rows. Each key should match a column name in your spreadsheet (wrap the column name in quotes if it contains spaces).

You can pass in an HTML element and all of the form fields will be parsed using their "name" attribute.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

godMode:
optional string

To bypass your security settings, enter a God mode key.

Result

A list of the updated SheetKit.Rows.

This example updates all movies released in 1990 and sets "Frank Oz" as their director.

SheetKit.DB.updateMany({
	sheet : 'Movies',
	query : {
		Year : 1990
	},
	data : {
		Director : 'Frank Oz'
	}
}, function(err, rows){
	// Handle failure or success
});

SheetKit.DB.removeOne

Removes a single row. You can also call a similar operation directly on SheetKit.Row objects. By default this is disabled. Update your security configuration to allow this operation.

Options

sheet:
required string

The name of the sheet that houses this data in your spreadsheet.

id:
required string

The unique id of the row you want to remove.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

godMode:
optional string

To bypass your security settings, enter a God mode key.

Result

None.

SheetKit.DB.removeOne({
	sheet : 'Movies',
	id : '...'
}, function(err, row){
	// Handle failure or success
});

SheetKit.DB.removeMany

Removes multiple rows by a query similar to the find operation. By default this is disabled. Update your security configuration to allow this operation.

Options

sheet:
required string

The name of the sheet that houses this data in your spreadsheet.

query:
optional object

The query to find rows to remove.

ignoreCase:
optional boolean

False to enforce case-sensitivity in searching. By default this is true.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

godMode:
optional string

To bypass your security settings, enter a God mode key.

Result

A count of the number of rows that were deleted

This example removes all movies released in 1990.

SheetKit.DB.removeMany({
	sheet : 'Movies',
	query : {
		Year : 1990
	}
}, function(err, count){
	// Handle failure or success
});

SheetKit.Row

Represents a single row in your spreadsheet.

Properties

sheet:
string

The name of the sheet that this row belongs to.

data:
object

The data stored in this row including the generated column "id" which is this row's unique identifier.

The SheetKit.Row constructor can be used to set properties.

var row = new SheetKit.Row({
	sheet : 'Movies',
	data : {
		Title : 'What About Bob?',
		Year : 1991
	}
});

SheetKit.Row.add

Persists the data in this object as a new row. SheetKit.DB.add is the preferred way of adding rows but this works, too!

Options

No options are needed, but the sheet and data properties for this row must be set.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

godMode:
optional string

To bypass your security settings, enter a God mode key.

Result

Your row object will have been updated with its new id, but for convenience it is also sent as a result to this operation.

var row = new SheetKit.Row({
	sheet : 'Movies',
	data : {
		Title : 'What About Bob?',
		Year : 1991
	}
});
row.add({}, function(err, row){
	// Handle failure or success
});

SheetKit.Row.get

Attempts to find this row and udpate its contents.

Options

No options are needed, but the sheet and data properties for this row must be set.

Result

Your row object will automatically be updated with it's latest data, but for convenience it is also sent as a result to this operation. If this row no longer exists, null will be returned instead of this row object.

var row = new SheetKit.Row();
row.get({
	sheet : 'Movies',
	id : '46d5c062-9b89-9a12-c577-64d81a33fb4c'
}, function(err, row){
	// Handle failure or success
});

SheetKit.Row.update

Updates the spreadsheet row with data in this object. This can only be called if sheet and data properties are set.

Options

data:
object HTMLElement

The data to update for this row. Any missing parameters will be left as they were.

You can pass in an HTML element and all of the form fields will be parsed using their "name" attribute.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

godMode:
optional string

To bypass your security settings, enter a God mode key.

Result

Your row object will have been updated, but for convenience it is also sent as a result to this operation.

row.update({
	data : {
		Director : 'Frank Oz'
	}									
}, function(err, row){
	// Handle failure or success
});

SheetKit.Row.remove

Removes this row from the spreadsheet. By default this is disabled. Update your security configuration to allow this operation.

Options

No options are needed, but the sheet and data properties for this row must be set.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

godMode:
optional string

To bypass your security settings, enter a God mode key.

Result

None.

row.remove({}, function(err){
	// Handle failure or success
});

SheetKit.Pay

First, make sure you've set up your payment configuration settings. SheetKit.Pay is a static class that lets you process credit card transactions.

SheetKit.Pay.chargeCard

Charges someone's credit card. If a Stripe customer ID is given, the customer's on-file credit card will be charged and the credit card field won't be required. Otherwise, unless you specify dontCreateCustomer, a new Stripe customer will be created so that you can charge their card again later.

Options

total:
required number

The amount to charge.

testMode:
required boolean

False to run live charges, otherwise everything runs in Stripe's test environment.

description:
optional string

The description of what's being charged. Your customers can see this text.

email:
optional string

The email where receipts will be sent for this customer.

currency:
optional string

The 3-character identifier for the currency of this transaction.

cardStatementDescription:
optional string

The description that will be displayed on the customer's credit card statement for this charge.

dontCreateCustomer:
optional boolean

True if you don't want Stripe to store this credit card for future use.

stripeCustomerID:
optional string

Specifies an existing customer in Stripe that you'd like to charge. If this value is specified, you can omit the card field and the customer's on-file card will be charged.

card:
required object HTMLElement

NOTE: not required if stripeCustomerID is used

Pass in a form element to collect data like this Stripe tutorial.

Or pass an object representing the details of a credit card:

number:
required string

The credit card number.

code:
required string

The security code for this card.

expMonth:
required string

The two-digit expiration month of the card.

expYear:
required string

The four-digit expiration year of the card.

Result

Information about the customer and created charge.

SheetKit.Pay.chargeCard({
	testMode : true,
	total : 24,
	description : 'Widget #1',
	card : {
		number : '4242424242424242',
		code : '123',
		expMonth : '12',
		expYear : '2018'
	}
}, function(err, result){
	// Result might look like:
	{
	   "stripeChargeID": "ch_15Ry43B9GmHV5skzyANVlxnT",
	   "stripeCustomerID": "cus_5dEX7XRSbOxFzO",
	   "amount": 2,
	   "testMode": true,
	   "cardBrand": "Visa",
	   "last4": "4242",
	   "expMonth": 12,
	   "expYear": 2015
	}
});

SheetKit.Pay.subscribe

Enrolls someone in one of your recurring subscription plans in Stripe. If a Stripe customer ID is given, the customer's on-file credit card will be charged and the credit card field won't be required. Otherwise a new Stripe customer will be created.

Options

plan:
required string

The Stripe ID of the subscription plan.

testMode:
required boolean

False to run live charges, otherwise everything runs in Stripe's test environment.

email:
optional string

An email address for this customer where receipts will be sent.

currency:
optional string

The default currency for this customer. This parameter is only applied when creating new Stripe customers. If using stripeCustomerID, their settings will remain as they already were.

coupon:
optional string

A Stripe coupon code to apply.

trialEnd:
optional date string

The date when this subscription's free trial will end and the subscription charge will be executed. You can specify the string "now" to expire a trial immediately.

quantity:
optional number

Not usually used, but you can multiple a customer's subscription cost by setting a quantity higher than 1. For example, if your plan is $10/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer charged $50 (5 x $10) monthly.

taxPercentage:
optional number

Add a tax percentage to your subscription (specify a number between 1 and 100).

stripeCustomerID:
optional string

Specifies an existing customer in Stripe that you'd like to charge. If this value is specified, you can omit the card field and the customer's on-file card will be charged.

card:
required object HTMLElement

NOTE: not required if stripeCustomerID is used

Pass in a form element to collect data like this Stripe tutorial.

Or pass an object representing the details of a credit card:

number:
required string

The credit card number.

code:
required string

The security code for this card.

expMonth:
required string

The two-digit expiration month of the card.

expYear:
required string

The four-digit expiration year of the card.

Result

The result of the customer and subscription created.

SheetKit.Pay.subscribe({
	testMode : true,
	plan : 'pro',
	card : {
		number : '4242424242424242',
		code : '123',
		expMonth : '12',
		expYear : '2018'
	}
}, function(err, result){
	// Result might look like:
	{
		"stripeSubscriptionID": "sub_5dSPkiWpv7NaHz",
		"stripeCustomerID": "cus_5dSOiC7wGrTF0z",
		"stripePlanID": "pro",
		"stripePlanName": "Pro",
		"testMode": true
	}
});

SheetKit.Pay.updateCard

Update's a customer's on-file credit card.

Options

testMode:
required boolean

False to run live charges, otherwise everything runs in Stripe's test environment.

stripeCustomerID:
required string

Specifies the customer in Stripe that you'd like to update.

card:
required object

An object representing the details of a credit card:

number:
required string

The credit card number.

code:
required string

The security code for this card.

expMonth:
required string

The two-digit expiration month of the card.

expYear:
required string

The four-digit expiration year of the card.

Result

None.

SheetKit.Pay.updateCard({
	testMode : true,
	stripeCustomerID : '...',
	card : {
		number : '4242424242424242',
		code : '123',
		expMonth : '12',
		expYear : '2018'
	}
}, function(err, result){
});

SheetKit.Pay.setPublishableKeys

This never needs to be called, but doing so will make the first operation on SheetKit.Pay execute faster.

NOTE: Unlike most methods, this method executes synchronously (no need for a callback).

Options

testPublishableKey:
required string

Specifies the publishable key from Stripe for test mode.

livePublishableKey:
required string

Specifies the publishable key from Stripe for live transactions.

Result

None.

SheetKit.Pay.setPublishableKeys({
	testPublishableKey : 'pk_test_pU4098765',
	livePublishableKey : 'pk_live_VM123456'
});

SheetKit.Notify

SheetKit.Notify is a static class that lets you send email notifications.

SheetKit.Notify.contactUs

Send a "contact us" email from the end user to your team.

Options

email:
required string

The email address of your end user.

message:
required string

The message they'd like to send to you.

recaptcha:
optional string

If you'd like your end users to pass Recaptcha, send in their recaptcha value here.

form:
optional HTMLElement

Instead of sending in email, message, and recaptcha, you can send in your form element instead.

Result

None.

SheetKit.Notify.contactUs({
	email : "john@customer.com",
	message : "Hello there! I have a question..."
}, function(err, result){
});

SheetKit.Remote

SheetKit.Pay is a static class to interact with remote resources like APIs.

SheetKit.Remote.send

Send remote HTTP requests from your spreadsheet and have the response proxied back to you.

In addition to getting around cross-origin problems, you can integrate with most any HTTP-based API. With some configuration, you can store secret values privately in your spreadsheet's settings (API keys for instance).

Options

url:
required string

The url to send this request to.

method:
optional string

The HTTP method to send (POST, GET, PUT, DELETE, etc.). Default is GET.

data:
optional object

A list of key-value pairs that will be sent as your HTTP payload.

format:
optional string

The type of data you expect the service to respond with: json, xml, plain, or base64.

ignoreErrors:
optional boolean

By default this is false and any response that represents a failure will result in an error object. If you need to parse the raw response for errors yourself, set this to true.

configuration:
optional string

Invokes the security options defined in your configuration so secret API keys can be added to requests or other customization can be performed.

getHeaders:
optional boolean

True to include the response headers in our result. Default is false.

recaptcha:
optional string

The value of Google's reCAPTCHA response to prove that this request came from a human interaction.

To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.

Result

Information about the response.

SheetKit.Remote.send({
	url : '...',
	method : 'POST',
	data : {
		param1 : 'value'
	},
	getHeaders : true,
	format : 'json'
}, function(err, result){
	
	// Result might look like:
	{
		headers : {
			header1 : 'value'
		},
		response : {
			// JSON from the service
		}
	}
});