Skip to content

Gets a random avatar URL from a collection of different avatar generation services.

License

Notifications You must be signed in to change notification settings

ClydeDz/give-me-an-avatar-npm

Repository files navigation


Give me an avatar npm package icon

Give Me an Avatar

Gets a random avatar URL from a collection of different avatar generation services.

Build status Azure DevOps tests Quality Gate Status Maintainability Rating MIT License npm Tweet about this

Usage

Install the package from npm using the following command.

npm i give-me-an-avatar

After installing, simply import Give Me an Avatar in your file.

const avatars = require("give-me-an-avatar");

Consume the giveMeAnAvatar() API to get an avatar URL that you can use directly as an image. You can either call the method without any parameters or supply the settings object to customize your avatar a bit. All settings are pretty self-explanatory and are not mandatory. For example:

let image = avatars.giveMeAnAvatar({
                Name: "John Smith",
                Size: 128
            }); 

The image variable will have the avatar image URL.

If you'd like to consume this package via a CDN, please see this demo.

Supported avatar services

Service Avatar example
placeholder.com image
placeimg.com image
placekitten.com image
dummyimage.com image
loremflickr.com image
baconmockup.com image
placebeard.it image
fakeimg.pl image
thispersondoesnotexist.com
picsum.photos image
fillmurray.com image
placecage.com image
stevensegallery.com image
gravatar.com image
ui-avatars.com image
generative-placeholders.glitch.me image
robohash.org image image image image
avatars.dicebear.com image image image image image image
avatar.uimaterial.com image image image image

Notes

  • I'm not using avataaars separately since avatars.dicebear.com includes avataaars.
  • Placekitten image might appear broken at times in the table above, however, the image service itself runs fine.

Credits

  • All the avatar services used in this npm package are outlined in the table above.
  • Package logo created using AutoDraw.
  • This NPM package is developed by Clyde D'Souza.