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

coffee_klout

v0.0.9

Published

Klout API v2 wrapper, Coffee style.

Downloads

5

Readme

coffee_klout

Wrapper for the Klout API v2. Only V2 and JSON calls (don’t tell me you miss XML). Accepts an optional Redis client to cache Klout API responses, especially identities.

Based on node_klout by Christopher John.

The userId hash

Most Klout endpoints use the Klout ID to get information about a user. This Klout ID is not directly related to the user’s other networks identities.

When exposing those endpoints, coffee_klout allows a hash instead of a Klout ID. It internally makes an additional call to Klout to convert the identity.

For a Twitter handle, the userId hash would be:

{
  "twitter_screen_name": "XXXXX"
}

For a Twitter ID (unique numeric ID, different from the username):

{
  "twitter_id": "XXXXX"
}

For a Google+ ID:

{
  "google_plus_id": "XXXXX"
}

For a Facebook Third-Party-ID:

{
  "third_party_id": "XXXXX"
}

And for consistency with the Klout API:

{
  "klout_id": "XXXXX"
}

Usage

Instantiate a new instance with your Klout API key

var Klout = require('coffee_klout');
var klout = new Klout({ key: '<YOUR_V2_KEY>' });

Resolve an identity (useful to retrieve the Klout user ID)

klout.getKloutIdentity(userIdHash, function(error, identity){
  // returns a Klout identity as documented by the Klout API v2 docs
  console.log(identity.id);
});

The following methods are supported, where klout_response is an object as documented by the Klout API v2 docs and klout_id_or_user_id_hash is documented above:

klout.getUser(klout_id_or_user_id_hash, function(error, klout_response) {
	// Returns a user object
});

klout.getUserScore(klout_id_or_user_id_hash, function(error, klout_response) {
	// Returns a user's score object
});

klout.getUserTopics(klout_id_or_user_id_hash, function(error, klout_response) {
	// Returns an array of user topics
});

klout.getUserInfluence(klout_id_or_user_id_hash, function(error, klout_response) {
	// Returns a user's influence object
});

Cache support

Klout suggests to store indefinitely Klout IDs obtained after requesting Klout identities. Without such cache or storage all calls basically cost 2 API calls because one is used to convert a Twitter/Facebook/Google+ user to a Klout user.

Optional parameters can be passed to coffee_klout so it internally stores Klout identities. It can also optionally cache other API reponses.

coffee_klout currently supports only Redis clients:

var redis = new require('redis').createClient();

var Klout = require('coffee_klout');
var klout = new Klout({
  key: '<YOUR_V2_KEY>',
  cacheClient: redis,
  cacheLifetime: 3600 // seconds
});

If cacheClient is present, all identities will be stored to avoid resolving twice the same user ID. If cacheLifetime is present (integer, seconds), other API calls are cached for the time specified.