npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

sheetdb-node

v0.0.12

Published

Official SheetDB API bindings for Node.js

Downloads

150

Readme

Installation

npm install sheetdb-node --save

Usage

Generating a Client

You need to create a new sheetdb function, and populate it with your SheetDB API URL. You can find this URL on SheetDB Dashboard.

var sheetdb = require('sheetdb-node');

// create a config file
var config = {
  address: '58f61be4dda40',
};

// Create new client
var client = sheetdb(config);

for ES6

import sheetdb from 'sheetdb-node';

// create a config file
var config = {
  address: '58f61be4dda40',
};

// Create new client
var client = sheetdb(config);

If you have HTTP Basic Authentication turned on for your API, you should pass auth_login and auth_password here, like:

// create a config file
var config = {
  address: '58f61be4dda40',
  auth_login: 'BASIC_AUTH_login',
  auth_password: 'BASIC_AUTH_password',
};

// Create new client
var client = sheetdb(config);

CRUD

SheetDB gives you the ability to use full CRUD on your Google Spreadsheet. Remember to populate the first row of every sheet with column names. You can look at example spreadsheet.

Create

Link to docs

To add data to Google Spreadsheets, send an object or an array of objects.

// Adds single row
client.create({ name: "William", age: 25 }).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

/// Adds bunch of rows
rows = [
  { name: "William", age: 25 },
  { name: "Jayden", age: 25 }
]
client.create(rows).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

By default, all writes are performed on the first sheet (worksheet). Pass name of a sheet as a 2nd param to add data to other worksheet.

// Adds single row to worksheet named "Sheet3"
client.create({ player: "William", score: 75 }, "Sheet2").then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

On success returns a number of created rows.

Read

Link to docs

Read the whole sheet

client.read({ limit, offset, search, sheet }).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

You can pass attributes with options

  • limit - limit number of results
  • offset - start from N first record
  • search - object with search params (more below)
  • sheet - get data from named worksheet
// Get first two rows from worksheet named "Sheet2"
client.read({ limit: 2, sheet: "Sheet2" }).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

// Get 3rd and 4th record from worksheet named "Sheet2"
client.read({ limit: 2, offset: 2, sheet: 'Sheet2' }).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

search

Link to docs

To get rows that match search criteria, pass an object with search params

// Get all rows where column 'id' is 'foo' and column 'value' is 'bar'
client.read({ search: { id: "foo", value: "bar" } }).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

// Get all rows where column 'First name' is 'Smith' and column 'Score' is '42'
client.read({ search: { 'first name': 'Smith', 'Score': 42 } }).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});


// Get first two rows where column 'player' is 'Smith',
// column 'score' is '41' from sheet named "Sheet2"
client.read({
  limit: 2,
  search: { 'player': 'Smith', 'score': 41 },
  sheet: 'Sheet2'
}).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

On success returns an array of objects.

Update

Link to docs

To update row(s), pass column name and its value which is used to find row(s).

client.update(columnName, value, newRow, sheet).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});
// Update all columns where 'name' is 'Smith' to have 'score' = 99 and 'comment' = 'Griffin'
client.update(
  'name', // column name
  'Smith', // value to search for
  { 'score': 99, 'comment': 'Griffin' } // object with updates
).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

To perform #update on different than the first sheet, pass sheet name as a 4th argument.

// Update all columns where 'name' is 'Smith' to have 'score' = 99 and 'comment' = 'Griffin'
// In sheet named 'Sheet2'
client.update(
  'name', // column name
  'Smith', // value to search for
  { 'score': 99, 'comment': 'Griffin' }, // object with updates
  'Sheet2'
).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

On success returns a number of updated rows.

Delete

Link to docs

To delete row(s), pass column name and its value which is used to find row(s).

// Delete all rows where 'name' equals 'Smith'
client.delete(
  'id', // column name
  '1' // value to search for
).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

You can pass sheet name as a 3rd argument. All operations are performed on the first sheet, by default.

// Delete all rows where 'foo' equals 'bar' in sheet 'Sheet3'
client.delete(
  player, // column name
  'Smith', // value to search for
  'Sheet2'
).then(function(data) {
  console.log(data);
}, function(err){
  console.log(err);
});

Development

Run all tests:

npm test

Run a nyan version test:

npm run nyan-test

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sheetdb/sheetdb-node. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Pull Requests

  • Add tests! Your patch won't be accepted if it doesn't have tests.

  • Create topic branches. Please, always create a branch with meaningful name. Don't ask us to pull from your master branch.

  • One pull request per feature. If you want to do more than one thing, please send multiple pull requests.

  • Send coherent history. Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before sending them to us.

Docs

SheetDB documentation sits on GitHub. We would love your contributions! We want to make these docs accessible and easy to understand for everyone. Please send us Pull Requests or open issues on GitHub.