This is a Node module for making requests using the official Google+ API (v1).
Important! This is an early version. It currently has no support (but should later on) for OAuth. Also, it assumes that when you request a user's activities they are of the public collection.
See the Google+ API docs for more on available parameter options. https://developers.google.com/+/api/
This module employs https, which come stock in Node. So you shouldn't have to npm anything.
The easiest way to install this module is to use npm. Execute npm install Google_Plus_API
in your terminal.
Using your API key you can create a new instance of the module as follows:
var GooglePlusAPI = require('google-plus-api');
var plus = new GooglePlusAPI('YOUR-API-KEY');
Once you have your instance you can get a user's profile by doing something like:
// id, callback
plus.getProfile('106180961098165812195', function(err, res) {});
// id, options, callback
plus.getProfile('106180961098165812195', { prettyPrint: 'true' }, function(err, res) {});
Getting a user's activities looks something like:
// id, callback
plus.getPublicActivities('106180961098165812195', function(err, res) {});
// id, options, callback
plus.getPublicActivities('106180961098165812195', { maxResults: 10 }, function(err, res) {});
Another way of doing it is:
// id, collection, callback
plus.getActivities('106180961098165812195', 'public', function(err, res) {});
Right now the only available collection is 'public,' but this allows some flexibility if and when that changes.
Once you have a list of activities from a user, you can then get more information for a specific one:
// activity id, callback
plus.getActivity('z134sdlycvycc5ufd22pedkz0rbijjnzm04', function(err, res) {});
One of the core features of Google+ is the 'Plus One,' similar to Facebook's 'Like.' You can find a list of 'Plusoners' like this:
// activity id, collection, callback
plus.getActivityPeople('z134sdlycvycc5ufd22pedkz0rbijjnzm04', 'plusoners', function(err, res) {});
The collection types are currently 'plusoners' and 'resharers.' You can also access this via a shortcut:
// activity id, callback
plus.getActivityPlusoners('z134sdlycvycc5ufd22pedkz0rbijjnzm04', function(err, res) {});
// activity id, callback
plus.getActivityResharers('z134sdlycvycc5ufd22pedkz0rbijjnzm04', function(err, res) {});
You may also want to dig deeper and look at the comments for the activity.
// activity id, callback
plus.getActivityComments('z134sdlycvycc5ufd22pedkz0rbijjnzm04', function(err, res) {});
As seen above you can retrieve the list of comments for a specific activity. But maybe you'd like to simply retrieve a single comment.
// comment id, callback
plus.getComment('i_gHb6AxAiPxyLxjJaW0gMItm0Eark-KwrOudJQ8F8Unt0muh-y4stTqGy_Tl24DKXYJWezdgDzlLveXdYO-Fg', function(err, res) {});
There are currently two types of searches available; Public activities and profiles.
// query, callback
plus.searchActivities('2012 election', function(err, res) {});
// query, callback
plus.searchProfiles('Marshall', function(err, res) {});
The Google+ API is still pretty young. There have already been a number of changes, and there are bound to be more. This module is subject to change.