gg

get-gravatar

Get a Gravatar image from an identifier, such as an email

Showing:

Popularity

Downloads/wk

49

GitHub Stars

33

Maintenance

Last Commit

9d ago

Contributors

5

Package

Dependencies

2

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

get-gravatar

Get a Gravatar image from an identifier, such as an email

Install

$ npm install get-gravatar

Usage

import fs from 'node:fs/promises';
import getGravatar from 'get-gravatar';

const image = await getGravatar('sindresorhus@gmail.com', {size: 200});
await fs.writeFile('sindre.png', image);

console.log('Successfully downloaded the Gravatar image');

API

getGravatar(identifier, options?)

Returns a promise for the image as a Buffer.

identifier

Type: string

The identifier for which to get the Gravatar image.

This will typically be an email matching a Gravatar profile, but can technically be any string.

The Gravatar service only sees a hash of the identifier, so you could actually use this to get pseudo-random avatars for any entity, e.g. based on its ID.

Note that if the identifier contains an @, it is assumed to be an email, and will therefore be lower-cased and trimmed before hashing, as per the Gravatar instructions - otherwise it will be hashed as-is.

options

Type: object

size

Type: number\ Default: 80\ Values: 1..2048

The size of the image.

default

Type: string\ Default: This image\ Values: Custom URL or 404, mm, identicon, monsterid, wavatar, retro, blank

The image to return if the identifier didn't match any Gravatar profile.

rating

Type: string\ Default: 'g'\ Values: 'g' | 'pg' | 'r' | 'x'

The allowed rating of the image.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100