Skip to content

js-mk/avatars

 
 

Repository files navigation

DiceBear Avatars

license npm

Avatars is a free pixel-art avatar placeholder library with HTTP-API.
Test in your Browser: avatars.dicebear.com

Usage

HTTP-API (recommended)

Our free HTTP-API is the easiest way to use Avatars. Just use the following URL as image source.

https://avatars.dicebear.com/v2/:sprites/:seed.svg

Replace :sprites with male, female or identicon. The value of :seed can be anything you like - but don't use any sensitive or personal data here!

CDN

Choose the CDN if you want to use a spriteCollection that is not available via the HTTP-API.

Add the following line to the end of the document body.

<script type="text/javascript" src="https://unpkg.com/@dicebear/avatars@2.0.0/dist/avatars.min.js"></script>

You also need to add a sprite collection. In our example, we will use the male sprite collection.

<script type="text/javascript" src="https://unpkg.com/@dicebear/avatars-male-sprites@1.0.0/dist/sprites.min.js"></script>

Now you are ready to create your first Avatar.

var avatars = new Avatars(Avatars.sprites.male);
var svg = avatars.create('custom-seed');

NPM

Choose NPM if you want to use Avatars server-side or with webpack.

Install the Avatars package with the following command.

npm install --save @dicebear/avatars

You also need to add a sprite collection. In our example, we will use the male sprite collection.

npm install --save @dicebear/avatars-male-sprites

Now you are ready to create your first Avatar.

const Avatars = require('@dicebear/avatars').default;
const SpriteCollection = require('@dicebear/avatars-male-sprites').default;

let avatars = new Avatars(SpriteCollection);
let svg = avatars.create('custom-seed');

Or with ES6-Modules:

import Avatars from '@dicebear/avatars';
import SpriteCollection from '@dicebear/avatars-male-sprites';

let avatars = new Avatars(SpriteCollection);
let svg = avatars.create('custom-seed');

Further informations

You can find the complete documentation at avatars.dicebear.com

About

Pixel-Art Avatar Generator by Identifier in JavaScript for Browsers and NodeJS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 74.3%
  • JavaScript 25.7%