Google Spreadsheet Data API -- simple interface to read and write rows and cells
A simple Node.js library to read and manipulate data in a Google Spreadsheet.
Works without authentication for read-only sheets or with auth for adding/editing/deleting data. Currently only supports list-based feeds (dealing with rows) as it seems more useful, but will probably add in cell-based feeds eventually.
npm install google-spreadsheet
var GoogleSpreadsheet = require"google-spreadsheet";var my_sheet = '<spreadsheet key>';// without auth -- read only// # is worksheet id - IDs start at 1my_sheetgetRows 1console.log 'pulled in '+row_datalength + ' rows '// set auth to be able to edit/add/deletemy_sheetsetAuth'<google email/username>''<google pass>'my_sheetgetInfoconsole.log sheet_infotitle + ' is loaded' ;// use worksheet object if you want to forget about idssheet_infoworksheets0getRowsrows0colname = 'new val';rows0save;rows0del;// column names are set by google based on the first row of your sheetmy_sheetaddRow 2 colname: 'col value' ;my_sheetgetRows 2start: 100 // start indexnum: 100 // number of rows to pull// do something...;
The Google Spreadsheets Data API reference and developers guide is a little ambiguous about how you access a "published" public Spreadsheet.
If you wish to work with a Google Spreadsheet without authenticating, not only must the Spreadsheet in question be visible to the web, but it must also have been explicitly published using "File > Publish to the web" menu option in the google spreadsheets GUI.
Generally, you'll find alot of public spreadsheets may not have had this treatment, so your best bet is to just authenticate a Google account and access the API in that manner.
This library uses googleclientlogin internally to provide basic authentication. Optionally you can pass in an auth token that you have created already (using googleclientlogin or something else).
node-google-spreadsheets is free and unencumbered public domain software. For more information, see the accompanying UNLICENSE file.