Home > node-gravatar

node-gravatar

Node-gravatar is a project mainly written in JavaScript, it's free.

Create gravatar URLs and use their API in node.js

gravatar.js for node.js

A library to assemble gravatar URLs for image and profile requests, as well as the JSON API.

Usage

gravatar.createHash(email)

Creates and returns a hash of the email address according to the gravatar implementation guide.

gravatar.imageUrlFor(hash[, options])

Assembles the image URL for the hash. options is a object with the following supported keys:

  • size: Integer (1-512) which will be the image size in pixel (defaults to 80px)
  • defaultImage: String (a URL or one of the constants documented here )
  • rating: Only show an image that matches this rating
  • format: A graphic format extension or 'qr' to get the QR Code image for the profile

gravatar.profileUrlFor(hash[, format, callback])

Assembles the profile URL for the hash. If format and callback are omitted the human-usable profile URL is generated. If format is set to 'json', the JavaScript API URL is generated. The callback parameter can be used to enclose the JSON data in a callback for client-side use.

gravatar.getProfileFor(hash, callback)

Retrieves the JSON profile data object via HTTP. callback is a function with two parameters: function(err, data) The data parameter will be set to the decoded JSON object retrieved from the API service.

Current TO-DO

  • Support other formats than JSON
  • Inline documentation