Klout API v2 wrapper, Coffee style.
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.
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:
For a Twitter ID (unique numeric ID, different from the username):
For a Google+ ID:
For a Facebook Third-Party-ID:
And for consistency with the Klout API:
Instantiate a new instance with your Klout API key
var Klout = require'coffee_klout';var klout = key: '<YOUR_V2_KEY>' ;
Resolve an identity (useful to retrieve the Klout user ID)
kloutgetKloutIdentityuserIdHash// returns a Klout identity as documented by the Klout API v2 docsconsole.logidentityid;;
The following methods are supported, where
klout_response is an object as documented by the Klout API v2 docs
klout_id_or_user_id_hash is documented above:
kloutgetUserklout_id_or_user_id_hash// Returns a user object;kloutgetUserScoreklout_id_or_user_id_hash// Returns a user's score object;kloutgetUserTopicsklout_id_or_user_id_hash// Returns an array of user topics;kloutgetUserInfluenceklout_id_or_user_id_hash// Returns a user's influence object;
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 = 'redis'createClient;var Klout = require'coffee_klout';var klout =key: '<YOUR_V2_KEY>'cacheClient: rediscacheLifetime: 3600 // seconds;
cacheClient is present, all identities will be stored to avoid resolving twice the same user ID.
cacheLifetime is present (integer, seconds), other API calls are cached for the time specified.