Skip to content
master
Switch branches/tags
Go to file
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

Search

<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

Packages

No packages published