Welcome to libgravatar’s documentation!


A library that provides a Python 3 interface to the Gravatar APIs.

class libgravatar.Gravatar(email)

This class encapsulates all the unauthenticated methods from the API.

get_image(size=80, default='', force_default=False, rating='', filetype_extension=False, use_ssl=True)

Returns an URL to the user profile image.

>>> g = Gravatar('myemailaddress@example.com')
>>> g.get_image()

With size you can request a specific image size, by default, images are presented at 80px by 80px. You may request image anywhere from 1px up to 2048px.

The default parameter is used to supply a default image when an email address has no match Gravatar image. default can be an URL or one of the built in options 404, mm, mp, identicon, monsterid, wavatar, robohash, retro or blank.

force_default force the default image to always load.

rating can be used to request images by audience type. Possible values are g, pg, r or x. By default, only g rated images are displayed.

filetype_extension add an optional .jpg extension.

use_ssl can be used to request images via SSL.

See more details on Gravatar Image Requests.

get_profile(data_format='', use_ssl=True)

Returns an URL to the profile information associated with the Gravatar account.

>>> g = Gravatar('myemailaddress@example.com')
>>> g.get_profile()

See more details on Gravatar Profile Requests.

class libgravatar.GravatarXMLRPC(email, apikey='', password='')

This class encapsulates all the authenticated methods from the XML-RPC API.

API details: http://en.gravatar.com/site/implement/xmlrpc


Gets a list of addresses for this account.


Checks whether a hash has a gravatar.


Test the API.


Returns a dict of userimages for this account.


Gravatar conditions for valid default URLs.

>>> default_url_is_valid('http://example.com/images/avatar.jpg')

Returns a md5 hash from a string.

>>> md5_hash('myemailaddress@example.com')

Returns an e-mail address in lower-case and strip leading and trailing whitespaces.

>>> sanitize_email(' MyEmailAddress@example.com ')

Indices and tables