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

download-google-spreadsheet

v0.1.1

Published

Download your Google Spreadsheets with Node.js.

Downloads

116

Readme

download-google-spreadsheet 0.1.1

Download your Google Spreadsheets with Node.js.

Usage

Get the API key:

  1. Visit Google Developers Console and create a project
  • Go to Overview then get into Drive API and Enable
  • Then API Manager / Credentials / Create credentials / OAuth client ID
  • Set Application type to Web application
  • Set Authorized redirect URIs to http://localhost:3477/ or your own value
  • Continue to Create and save your new credential

Then export to environment variables: DGSS_CLIENT_ID, DGSS_CLIENT_SECRET and DGSS_REDIRECT_URL. Or save them into .env under the working directory if you want, then:

$(npm bin)/download-google-spreadsheet '[{"fileId":"11KmsfhX7M0q3dwLSYiUAIIbov8qHvvhLcxqJzv9o1Pw","gid":"0"}]'

If no cached token .dgsstoken can be found under current directory, you will be prompted to a Google OAuth page for you to authorize your API key to access the spreadsheets. The token will then be cached and you will not be prompted again until the expiration.

After that, the test spreadsheet will be downloaded into current working directory as 0.csv. The CSV file will be named as gid by default if there is no dest attribute defined for that sheet.

You can find the fileId and gid attributes from the link to your spreadsheet: https://docs.google.com/spreadsheets/d/11KmsfhX7M0q3dwLSYiUAIIbov8qHvvhLcxqJzv9o1Pw/edit#gid=0

API

var downloadGoogleSpreadsheet = require('download-google-spreadsheet');

var sheets = [{
  dest: './somedir/test.csv',
  fileId: '11KmsfhX7M0q3dwLSYiUAIIbov8qHvvhLcxqJzv9o1Pw',
  gid: '0',
}];

var opts = {
  id: '686354652584-fule4tvfhelci96apnb368bsu3d1st9c.apps.googleusercontent.com',
  redirect: 'http://localhost:3477/',
  secret: 'OeBRLzWNkwMOdjDe5HyHqIiZ',
};

downloadGoogleSpreadsheet(sheets, opts, function (err) {
  if (err) throw err;
  console.log('Done.');
});

Options

  • id Google OAuth client ID
  • redirect Must be one of the Authorized redirect URIs in credential settings
  • secret Google OAuth client secret

Development

npm run dev, code ./src/**/*.js, then ./bin/download-google-spreadsheet.js to try.

Releases

| Date | Version | Description | |------------|---------|-----------------| | 2016-03-28 | 0.1.1 | Fix callback | | 2016-03-27 | 0.1.0 | Initial release |

TODOs

  • Support stdin and pipe
  • Support CLI-only environment
  • Show feedbacks to screen
  • Expose more options
  • Update build script to produce readable scripts
  • Update readme
  • Cache multiple tokens for multiple spreadsheets
  • Code linting
  • Test