1.0.3 • Published 6 years ago
@tomwaferry/google.api.helper
Licence
ISC
Version
1.0.3
Deps
1
Size
7 kB
Vulns
0
Weekly
0
Google API helper module
Simple module for interacting with Google APIs.
Initialising
You'll need a service to service authentication JSON file to authenticate requests. You can generate one from the (Google Cloud Console)[https://console.cloud.google.com/home/dashboard?project=entee.co.uk:api-project-577903765002].
Require that in and create a new instance of the Google Helper with your key.
const googleHelper = require('@tomwaferry/google.api.helper');
const key = require('/path-to-service-account.json');
const google = new googleHelper(key);
Methods
The following methods are available and all return promises:
- readGoogleSheet
- appendGoogleSheet
- clearGoogleSheet
- batchUpdateGoogleSheet
- uploadGoogleDriveImage
- listDriveFolderContents
- getSearchConsoleData
Remember to grant your service account permissions on the applicable resources.
Usage
All methods return promises, and can be used like so:
// Promises
google.readGoogleSheet('spreadsheetId', 'Sheet1', 'A:E').then(data => {
// do something with the data
});
// Async Await
async function(){
const data = await google.readGoogleSheet('spreadsheetId', 'Sheet1', 'A:E');
// do something with the data
}