gravitate

Yet another node library for Gravatar with support for both the photo and profile APIs.

Gravitate

Yet another node library for Gravatar with support for both the photo and profile APIs.

Although all of the gravitate functions can accept an email, there is still a hash function available for your use. If the input has already been hashed then it will just return the value.

var gravitate = require('gravitate');
var email = 'email@address.com';
var hash = gravitate.hash(email); // "63b91ca4ec19ad79f320eaf5815d75e9" 

ignorePlus - Ignore characters after and including a + sign. Defaults to true.

var hash = '63b91ca4ec19ad79f320eaf5815d75e9';
var imageUrl = gravitate.image.url(hash); // "https://secure.gravatar.com/avatar/63b91ca4ec19ad79f320eaf5815d75e9" 

All functions also accept an email:

var email = 'email@address.com';
var imageUrl = gravitate.image.url(email); // "https://secure.gravatar.com/avatar/63b91ca4ec19ad79f320eaf5815d75e9" 

Image and profile urls are secure by default. You can toggle SSL by setting the secure property in options to true or false.

var email = 'email@address.com';
var imageUrl = gravitate.image.url(email, {secure: false}); // "http://www.gravatar.com/avatar/63b91ca4ec19ad79f320eaf5815d75e9" 

All of the standard url options are also available either through their full or abbreviated name:

var email = 'email@address.com';
var imageUrl = gravitate.image.url(email, {
  default: 'monsterid',
  r: 'pg'
});

Profile urls work the same way as image urls and also accept a secure parameter:

var email = 'email@address.com';
var profileUrl = gravitate.profile.url(email); // "https://secure.gravatar.com/63b91ca4ec19ad79f320eaf5815d75e9.json" 

Often times you'll want the actual data and not url. You can get the profile data with the following function:

var email = 'email@address.com';
var profileUrl = gravitate.profile.data(email, function (errdata) {
  if (err) return;
  console.log(data.entry[0]); // {hash: '...', photos: [], ...} 
});