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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sheets-api

v1.0.8

Published

A Google Sheets API v4 implementation that abstracts authorization.

Downloads

57

Readme

Sheets API v4

Allows you to start working with the Google Sheets API v4 right away.

A Google Sheets API v4 implementation that abstracts the authorization portion of each request away from the user a bit. Simply call authorize to get a promise that resolves the OAuth2 client which can be used to make requests. Provides generic 'collection' methods that assist with calling methods associated with those collections i.e. 'values' maps to spreadsheets.values. Really just a wrapper around googleapis.

Here's how to use it:

Visit Node quickstart and complete Step 1 to get your client_secret.json.

npm i sheets-api --save
// sheets-client.js
const SheetsAPI = require('sheets-api');
const sheets = new SheetsAPI();
const SPREADSHEET_ID = "19uTpwB-PM9TtUGUCRMdgWdkH0pqEHVv3J6sjzCNoMRM";

// ValueRange(https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange)
let payload = {
  spreadsheetId: SPREADSHEET_ID,
  range: "Orders!A1:D1",
  valueInputOption: 'USER_ENTERED',
  resource : {
    majorDimension: "ROWS",
    values: [
      ["Door", "$15", "2", "3/15/2017"],
      ["Engine", "$100", "1", "3/20/2016"]
    ]
  }
}

sheets
  // Get me an authorized OAuth2 client thats ready to make requests.
  .authorize()

  // https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
  // Using the spreadsheets.values collection, use the 'append' method to
  // append data (payload) to a spreadsheet.
  .then(auth => sheets.values('append', auth, payload))

  // 'response' is an object that contains the response from the request to the
  // API (append) and the OAuth2 client to be chained further. It looks like this:
  // {auth:auth, response:response}
  .then(response => sheets.values('get', response.auth, {
    spreadsheetId: SPREADSHEET_ID,
    range: 'Orders!A1:D1'
  }))

  // The results of the request to spreadsheets.values.get collection.
  .then(response => {
    console.log(response.response);
  })

  // Derp
  .catch(e => console.error(e))

Zoolander - Its so simple

##Change Log

1.0.5 - Jan 8, 2017

Fixing typo where response was undefined.

1.0.4 - Jan 8, 2017

Publishing README.md to NPM.

1.0.3 - Jan 8, 2017

Fixed fn#collections not correctly resolving the response from sheets api. Promise.resolve takes a single object. You can't simply pass n arguments to it. It has single arity.

1.0.2 - Jan 5, 2017

Fixed not returning promises from collection methods.

1.0.1 - Jan 5, 2017

Added other collection helper methods (spreadsheets.sheets, spreadsheets).

1.0.0 - Jan 4, 2017

Initial publish.