Libraries

If a library or plugin is not availble for your language or application, your best option at the moment is to use our simple API. Don't worry though, it's really not that much work!

C#

Chris Forbes is maintaining the C# bindings.

using libravatarsharp;
var uri = AvatarUri.FromEmail( "someone@example.com" );

(!) The library does not support federation.

node.js

There is a Libravatar node.js module that can be used in the following way:

var libravatar = require('libravatar');
libravatar.url(email='person@example.com', openid=null, { size: 96, default: 'mm' }, https=false,
  function (error, avatar_url) {
    console.log('<img src="' + avatar_url + '">');
  });

Perl

The Libravatar::URL module is part of the Gravatar::URL package (libgravatar-url-perl in Debian and Ubuntu) since version 1.03.

use Libravatar::URL;
my $avatar_url = libravatar_url(email => 'person@example.org');
print '<img src="' . $avatar_url . '">';

As of version 1.04, you can also use OpenID URLs instead of email addresses:

my $avatar_url = libravatar_url(openid => 'https://example.com/id/person');

PHP

Melissa Draper maintains the Services_Libravatar PEAR package. Here's an example of how it works:

require_once 'Services/Libravatar.php';
$libravatar = new Services_Libravatar();
$avatar_url = $libravatar->getUrl('person@example.org');
print '<img src="' . htmlspecialchars($avatar_url) . '" alt="avatar"/>';

or like this for OpenID-based avatars served over HTTPS:

$avatar_url = $libravatar->getUrl('http://example.org/id/Person', array('https' => true));

Python

The pyLibravatar module can be used like this:

from libravatar import libravatar_url
avatar_url = libravatar_url(email = 'person@example.org')
print '<img src="' + avatar_url + '">'

Qt5

The source code for Rawatar can be found on git.kde.org

Ruby

Kang-min Liu has created a Libravatar Ruby gem.

require 'libravatar'
avatar_url = Libravatar.new(:email => 'person@example.org')
print '<img src="', avatar_url, '">'

You can also use :openid => 'https://example.com/id/person' instead of providing an email address.

Twisted

The txLibravatar module can be used like this:

from txlibravatar import libravatar_url
d = libravatar_url(email = 'person@example.com')
d.addCallback(lambda x: print '<img src="' + x + '">')

Plugins

There aren't many plugins available at the moment, but please suggest the ones you'd like to have.

Contribute!

Interested in writing a plugin for your favourite framework/CMS or a library for your favourite language? Please get in touch, we would be more than happy to link to them from this page!