Google Spreadsheets fetcher for node.js & CLI
Lightweight & easy-to-use library to get Google Spreadsheets with Node.js or command-line.
- works ONLY with shared spreadsheets (don't be confused with 'Publish to Web')
- easy to start using: simple API gives just neccessary options
- Can be used inside your app via Node.js
- Or CLI when JSON file with sheets data is all you need
Installation
For CLI (command-line)
npm install -g sheets-to-json
For Node.js
npm install --save sheets-to-json
Before start
You need to get table-Id from spreadsheets you want to obtain:
- Go to the page with your spreadsheet
- Check if spreadsheet is shared and availiable by link
- How to find ID => **https://docs.google.com/spreadsheets/d/
**\*\*\*\***\*YOUR**_ID_**GOES\_\_\_HERE\*\***\*\*\*\*\*
** - highlighted is table ID
Usage
CLI
$ gsdata --helpUsage: gsdata <table-id> [filename] [options] Options: -V, --version output the version number -j, --json Convert TSV to JSON -h, --help output usage information
Notes
table-id
is required. By callinggsdata 'your-id-goes-here'
result will be printed directly in CLIfilename
is optional. Type thepath/to/your/file.json
aftertable-id
and result will be written as JSON file.- Right now
options
consists only of-j
or--json
. Can be used instead of or afterfilename
- converts obtained sheets' data from TSV to JSON (see Examples)
Node.js
; ;
Notes
tableId
is required. By calling
;
result will be printed in console.
filename
is optional.
;
result will be written as JSON file.
- Right now
options
consists only of
options: json: true;
Can be used instead of or after file
;
to convert obtained sheets' data from TSV to JSON (see Examples)
Examples
Get JSON with plain TSV data printed into console:
CLI:
$ gsdata 5G9YfhYY******
Node.js:
;
+ data converted from TSV to JSON: CLI:
$ gsdata 5G9YfhYY****** -j
Node.js:
;
Write JSON with plain TSV data into file:
CLI:
$ gsdata 5G9YfhYY****** path/to/file.json
Node.js:
;
+ data converted from TSV to JSON: CLI:
$ gsdata 5G9YfhYY****** path/to/file.json -j
Node.js:
;
Features
- This library is inteneded to work ONLY with shared spreadsheets - it doesn't use any side APIs or packages to fetch data, just plain request as if you did in your browser.
- It doesn't need any sort of authentication so you don't have to waste your time doing all those side actions. Great for collaboration teams.
- It's an exporting tool ONLY (can't write anything back to your spreadsheet).
- ... but it's open for new features! Contact me or send pull request if you have something to bring in.
Author
Roman Shalman
License
GNU General Public License v3.0, see LICENSE