Skip to content

sheetdb/sheetdb-js

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

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

SheetDB JavaScript Client

JavaScript Library for accessing google spreadsheet content via SheetDB. https://sheetdb.io

Installation

The SheetDB JS Library is available through npm

npm install sheetdb-js --save

Test spreadsheet

At any time you can play with our test API here: https://sheetdb.io/api/v1/58f61be4dda40

You can also go to Google Sheets and play with it: https://docs.google.com/spreadsheets/u/2/d/1mrsgBk4IAdSs8Ask5H1z3bWYDlPTKplDIU_FzyktrGk/edit The spreadsheet resets every hour.

Basic usage

In order to instantiate SheetDB connection you need to give an api id. You can find it in SheetDB Dashboard.

ES6:

import SheetDB from 'sheetdb-js'

SheetDB.read('https://sheetdb.io/api/v1/58f61be4dda40', {}).then(function(result){
  console.log(result);
}, function(error){
  console.log(error);
});

or require method

require('sheetdb-js');

SheetDB.read('https://sheetdb.io/api/v1/58f61be4dda40', {}).then(function(result){
  console.log(result);
}, function(error){
  console.log(error);
});

If you don't use any boundler you can import a script from our servers like so:

<script src="//sheetdb.io/api/js"></script>
<script>
SheetDB.read('https://sheetdb.io/api/v1/58f61be4dda40', {}).then(function(result){
  console.log(result);
}, function(error){
  console.log(error);
});
</script>

There is also Pen you can play with: https://codepen.io/sheetdb/pen/qpmodo

<script src="//sheetdb.io/api/js"></script>
<script>
SheetDB.read('https://sheetdb.io/api/v1/58f61be4dda40', { search: { age: 24 } }).then(function(result){
  console.log(result);
}, function(error){
  console.log(error);
});
</script>

Multiple spreadsheets

<script src="//sheetdb.io/api/js"></script>
<script>
SheetDB.read('https://sheetdb.io/api/v1/58f61be4dda40', { sheet: 'Sheet2', search: { score: 41 } }).then(function(result){
  console.log(result);
}, function(error){
  console.log(error);
});
</script>

Create new rows

<script src="//sheetdb.io/api/js"></script>
<script>
SheetDB.write('https://sheetdb.io/api/v1/58f61be4dda40', { sheet: 'Sheet2', data: {player: 'Test', score: 41} }).then(function(result){
  console.log(result);
}, function(error){
  console.log(error);
});
</script>

About

JavaScript Library for accessing google spreadsheet content via SheetDB.

Resources

Stars

Watchers

Forks

Packages

No packages published