npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gapi

v0.0.3

Published

Node implementation of Google's JavaScript Library (Currently Implemented: Google+ & Google WebFonts)

Downloads

20,392

Readme

A Node.js implementation of the "JavaScript Client Library for Google APIs - Alpha version"

Installation

To install gapi locally, use npm:

$ npm install gapi

To install gapi globally, use npm:

$ npm install -g gapi

Usage

Include gapi

var gapi = require('gapi');

To get started, set your API key with gapi.server.setApiKey():

gapi.server.setApiKey('YOUR_API_KEY');

You can then use gapi.server.load('API_NAME', 'API_VERSION', CALLBACK) to load the API you wish to use:

gapi.server.load('plus','v1',function(){});

Inside your load callback, you can generate your requests using the gapi.server.API_NAME.NAMESPACE.FUNCTION(OPTIONS) pattern:

var request = gapi.server.plus.people.get({userId: '102147307918874735077'});

To execute your request, you can call REQUEST.execute(CALLBACK(RESPONSE)):

request.execute(function(resp){});

The response of the callback is a JSON object that you can work with:

res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(JSON.stringify(resp));

Putting it all together:

gapi.server.setApiKey('YOUR_API_KEY');
gapi.server.load('plus','v1',function(){
	var request = gapi.server.plus.people.get({userId: '102147307918874735077'});
	request.execute(function(resp){
		res.writeHead(200, {'Content-Type': 'text/plain'});
		res.end(JSON.stringify(resp));
	});
});

Currently Implemented Request Functions and Options

Google+ V1 ('plus','v1')

Get One Activity

/*
 *
 * activityId is Required
 *
 */
gapi.server.plus.activities.get({
	activityId : '',
	fields : ''
});

List Activities of One User

/*
 *
 * userId and collection are Required
 * collection : 'public' is the only available option currently
 * maxResults can be an integer from 1-100
 *
 */
gapi.server.plus.activities.list({
	userId : '',
	collection : 'public',
	maxResults : 100,
	pageToken : '',
	fields : ''
});

Search all Activities using Query

/*
 *
 * query is Required
 * separate words in query with a +
 * maxResults can be an integer from 1-20;
 *
 */
gapi.server.plus.activities.search({
	query : '',
	language : '',
	maxResults : 20,
	orderBy : '',
	pageToken : '',
	fields : ''
});

Get One Comment

/*
 *
 * commentId is Required
 *
 */
gapi.server.plus.comments.get({
	commentId : '',
	fields : ''
});

List All Comments of One Activity

/*
 *
 * activityId is Required
 * maxResults can be an integer from 0-100;
 *
 */
gapi.server.plus.comments.list({
	activityId : '',
	maxResults : 100,
	pageToken : '',
	fields : ''
});

Get One Person

/*
 *
 * userId is Required
 *
 */
gapi.server.plus.people.get({
	userId: '',
	fields : ''
});

List the PlusOners or Resharers of One Activity

/*
 *
 * activityId and collection are Required
 * collection can be either 'resharers' or 'plusoners'
 * maxResults can be an integer from 1-100;
 *
 */
gapi.server.plus.people.listByActivity({
	activityId: '',
	collection: '',
	maxResults: 100,
	pageToken : '',
	fields : ''
});

Search all People using Query

/*
 *
 * query is Required
 * separate words in query with a +
 * maxResults can be an integer from 1-20;
 *
 */
gapi.server.plus.people.search({
	query : '',
	language : '',
	maxResults : 20,
	orderBy : '',
	pageToken : '',
	fields : ''
});

Google Webfonts V1 ('webfonts','v1')

Retrieves the list of fonts currently served by the Google Web Fonts Developer API

/*
 *
 * none are Required
 * sort can be: 'alpha', 'date', 'popularity', 'style', or 'trending'
 *
 */
gapi.server.webfonts.webfonts.list({
	sort : '',
	fields : ''
});

Examples

You can view further examples in the example folder.

Running the Express example is as easy as entering (in terminal)

$ cd ./node_modules/gapi/examples/express-example/ && npm install ./ && node app.js

Tests

$ npm test gapi

LICENSE

(MIT License)

Copyright (c) 2011 Phated [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.