GNOS - Googleapi Now Over Simplificated - google api wrapper to make it easier to use !
npm install gnos- cache handling in read operations
- api call delays & queue to stay in the range of google limitations
- error management : will await until google API is available again in case of error, will throw an error if not available during 120s or if a single request takes more than 120s to be executed
Service accounts allow you to perform server to server, app-level authentication using a robot account. You will create a service account, download a keyfile, and use that to authenticate to Google APIs. To create a service account:
- Go to the Create Service Account Key page
- Select New Service Account in the drop down
- Click the Create button
Save the service account credential file somewhere safe, and do not check this file into source control !
On the left menu go to APIs and services / Enabled APIs and services
Click on the top button + ENABLE APIS AND SERVICES
Type spreadsheet in the search bar
Click on the result, then on the button ENABLE
https://www.googleapis.com/auth/spreadsheets
install packagenpm i gnos
import libraryimport { sheetAPI } from "gnos";
set your path to auth.json, include filename in the path (ex. "./auth.json")sheetAPI.setAuthJsonPath(
#### READ operations :
- getTabIdssheetAPI.getTabIds({sheetId:string, disableCache?: boolean}) => Promise
return list of sheet tabs with their respective IDs
- getTabDatasheetAPI.getTabData({sheetId:string, tabName:string, headerRowIndex?:number, tabList?:TabListItem[], disableCache?: boolean}) => Promise
return tab data in the form of an array of objects built according to header values
- getTabSizesheetAPI.getTabData({sheetId: string, tabName: string) => Promise
return columns & rows count for a tab
- clearCachesheetAPI.clearCache() => void
clear all of the above operations cache
- getProtectedRangeIdssheetAPI.getProtectedRangeIds({sheetId: string, tabName: string) => Promise
get all protectedRange ids of a defined tab
#### WRITE operations :
- updateRangesheetAPI.updateRange({sheetId: string, tabName: string, startCoords: [number, number], data: any[][]}) => Promise
update a specific range
- appendToSheetsheetAPI.appendToSheet({sheetId: string, tabName: string, data: Data[]}) => Promise
append a line of data to second line of a tab (matching headers)
- addBatchProtectedRangesheetAPI.addBatchProtectedRange({sheetId: string, editors: string[], namedRangeId?: string, tabId: number, startColumnIndex: number, startRowIndex: number, endColumnIndex: number, endRowIndex: number}) => void
add a request to batch buffer
- runBatchProtectedRangesheetAPI.runBatchProtectedRange({sheetId: string, onTimeoutCallback:() => Promise
run all requests in batch buffer, "onTimeoutCallback" will be run if request takes more than 120s to be executed
- deleteProtectedRangesheetAPI.deleteProtectedRange({sheetId: string, protectedRangeIds:number[]}) => Promise
delete a list of protected range ids
- clearTabDatasheetAPI.runBatchProtectedRange({ sheetId: string, tabName: string, headerRowIndex?: number, tabList?: TabListItem[]}) => Promise
clear all values of a defined tab
#### MISC
- enableConsoleLogsheetAPI.enableConsoleLog() => void
turns on logs with detailed infos over cache usage & delay between requests
- clearBuffersheetAPI.clearBuffer() => void
clear all requests batch buffer
- getBatchProtectedRangesheetAPI.getBatchProtectedRange() => {[key: string]: sheets_v4.Schema$Request[];}
return all requests in batch buffer