GitHub - cohere-io/google-api-client: A REST-based client for the Google Analytics API. Supports Promises and Request Queueing · GitHub
Skip to content

cohere-io/google-api-client

Folders and files

Repository files navigation

3/23/17 : 2.1.0 modifies, yet again, how the client is instantiated. See the example below.

A simple example:

const google          = require('google-api-client'),
      queryParams     = {
        'start-date'    : '2017-03-01',
        'end-date'      : '2017-03-31',
        'ids'           : 'ga:[TABLE_ID]',
        'dimensions'    : 'ga:date',
        'metrics'       : 'ga:sessions'
      };

return new Promise(function(resolve, reject) {

    var Client = new google.ApiClient([CLIENT_ID]);

    Client.oauth2.refreshToken([REFRESH_TOKEN], [CLIENT_SECRET])
    .then(function(accessToken) {
	    Client.setAccessToken(accessToken);
	    return Client.analytics.data.get(queryParams);
    })
    .then(function(result) {
	    console.log(result);
    })
    .catch(function(error) {
	    console.log(error);
    });
};

About

A REST-based client for the Google Analytics API. Supports Promises and Request Queueing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors