Node.js library to read from Google Sheets API (v4) and convert to JSON collection
npm install googlesheet-to-json
npm install googlesheet-to-json --save
`$3
See getting credentialsCLI
`
npm install -g googlesheet-to-json
googlesheet-to-json -s 'Sheet1' > out.json
`API
`
// see 'Getting Credentials' below
const { private_key, client_email } = require('./googleServiceAccount.json')
const GoogleSheetToJSON = require('googlesheet-to-json')
const gSheetToJSON = new GoogleSheetToJSON({ private_key, client_email })const spreadsheetId = '1gTERIVPV_0yoMXc6mlBtBpNvaoH5pIU2IC-75V_Qcas'
const range = 'Sheet1'
gSheetToJSON.getRows({ spreadsheetId, range })
.then(rows => console.log('rows:', rows))
.catch(console.error)
`----
Getting credentials
1. Login to Google API console
1. Create 'Service Account' credentials @ https://console.developers.google.com/apis/credentials
1. Download credentials json file and rename to
googleServiceAccount.json
1. Copy googleServiceAccount.json to root of your project and add to .gitignore`