Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bradoyler/googlesheet-to-json
Tool to read 📊 v4 GoogleSheets API and convert to JSON collection
https://github.com/bradoyler/googlesheet-to-json
Last synced: 17 days ago
JSON representation
Tool to read 📊 v4 GoogleSheets API and convert to JSON collection
- Host: GitHub
- URL: https://github.com/bradoyler/googlesheet-to-json
- Owner: bradoyler
- Created: 2017-11-02T13:08:24.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-10T18:43:28.000Z (about 6 years ago)
- Last Synced: 2024-10-11T01:14:19.010Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 48.8 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Googlesheet-to-json
Node.js library to read a Google Sheet (v4) and convert to JSON collection## Install
```
npm install googlesheet-to-json --save
```### Setup Google API credentials (Service Account)
[See getting credentials](#getting-credentials)## CLI
```
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 credentials1. Login to [Google API console](https://console.developers.google.com)
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`