npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gravatar.js

v2.0.0

Published

A promise-based Gravatar client for Node and the browser

Readme

Gravatar

A promise-based Gravatar client for Node and the browser. See demo here.

Build Status Code Climate

Current version: 2.0.0

Install

npm install --save gravatar.js

Description

This library covers most of the accessible interfaces exposed by the Gravatar service and makes them accessible in the context of a browser or a Node.js application. For features requiring a bit more than simply just returning an URL to an image associated with an e-mail address, this module uses asynchronous requests accessible through a promise-based API to resolve remote resources.

Usage

Requiring the library

The entry point of the library can be required through different means, each one depending on the environment in which the library is executed.

ESM

import gravatar from 'gravatar.js';

Common JS

const gravatar = require('gravatar.js');

Browser (ESM)

import gravatar from 'https://esm.sh/gravatar.js/dist/index.esm.js'

Browser (UMD)

<script src="./dist/index.umd.js"></script>

Associating an e-mail with an avatar

To do so, you simply need to pass an e-mail address to the library :

const url = gravatar.url('foo@bar');

It is also possible to pass several options to this method in order to customize the behaviour of the Gravatar interface :

const url = gravatar.url('foo@bar', { defaultIcon: '404', size: 200 });

You will find below the list of supported parameters you can pass to the library.

Option key | Description ------------- | ------------- defaultIcon | The adopted behaviour when no image is associated with the given e-mail address. The default value is 404. size | The size of the image in pixels. The default value is 80 pixels. rating | Defines whether to retrieve an avatar given its category, or rating. Take a look here for more informations. The default value is G.

Retrieving user profiles

It is possible through the Gravatar API to retrieve a collection of profile objects associated with a user. Using this library it is possible to retrieve this collection using the user e-mail address.

// `profiles` is an array of profile objects associated
// with the given e-mail address.
const profiles = await gravatar.profiles('foo@bar');

Resolving an e-mail address

Simply generating an URL given an e-mail address does not mean this URL does actually point to an existing resource. As such, this library provides an interface used to resolve the given e-mail address to a valid avatar URL.

// `url` will contain the url to the *main* thumbnail
// associated with the given e-mail address.
const url = await gravatar.resolve('foo@bar');

Similarly to when you generate an URL, you can pass an optional object as a second argument to the .resolve method in order to specify how you would like the avatar to be resolved. If the avatar has been resolved, it will be passed as an argument to the success callback.