1.0.3 • Published 4 years ago

@tomwaferry/google.api.helper v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

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: 1. readGoogleSheet 2. appendGoogleSheet 3. clearGoogleSheet 4. batchUpdateGoogleSheet 5. uploadGoogleDriveImage 6. listDriveFolderContents 7. 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
}
1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago