Due to google shutting down the previous spreadsheet API, gsheets 3.0.0 now uses the official sheets API v4, which requires an GSHEETS_API_KEY. You may provide it via the environment or a .env
file when using the CLI.
The new API does not return any meaningful metadata of the spreadsheets and allows for direct query of a worksheet by it's title. Thus the methods gsheets.getWorksheetById and gsheets.getSpreadsheets have been removed.
Now:
gsheets.getWorksheet('SPREADSHEET_KEY', 'WORKSHEET_TITLE')
Due to the GSHEETS_API_KEY requirement, using this library client-side has become obsolete. V3 removes the build steps which create gsheets.polyfill.js files.
gsheets now uses Promises instead of callbacks. Everything else stays the same.
Before:
gsheets.getWorksheet('ABC', 'xyz', (error, result) => {/*...*/});
Now:
gsheets.getWorksheet('ABC', 'xyz')
.then(result => {}, error => {});
Also, empty worksheets now contain an empty array as data
instead of null
.