API Documentation

We made it very simple to incorporate personalized avatars into your apps and websites.

Getting Started

Introduction


AvartarGen.io provides an API that allow users to generate avatars based on specified features. Developers are able to integrate our service within their apps and websites — allowing their users to create personalized avatars.

We provide many features for each avatar type (male and female). However, you may only need a specific subset. Choose the features suitable for your use case. Randomly generated avatars are also available.

Have a question or comment about this documentation? contact us.

Authentication


An API key is needed to access our service — if you do not have one, request one here. If you need to regenerate your API key, please contact us.

The API key should be placed in the header on each request. Please note the use of camel case: apiKey.

key (header) field

apiKey=YOUR-API-KEY

Requests


To make a request to our API, use HTTP POST. The URL should include the base URL plus the desired avatar's URI. The request body should contain only the features (name-value pairs) required to generate the male avatar or the female avatar.

Base URL: https://avatargen.io/api/generator

Male avatar image

Generating a male avatar

URI: /male

The male avatar is the first of the two types available. There are a number of features available to build it to a specific liking.

Feale avatar image

Generating a female avatar

URI: /female

The female avatar is the second of the two types available. Similar to the male, there are a number of features available to build it to a specific liking.

Random avatar image

Generating a random avatar

URI: /random

A random avatar is one where the features of the avatar are randomly generated. The avatar's gender is required to build a random male or female avatar.

Useful tips to consider

Your API key has a daily request quota — design your user-flow to best utilize the number of requests available.

  • Consider sending requests in batches versus on demand. One useful tip is to let your users select all their desired features before making an API request. Once all the features are selected, make the request to our API and display the returned avatar.
  • Consider storing data both client-side and server-side. Another useful tip is to save the user's avatar locally (client-side) while storing the selected features server-side (database). When your user needs a new copy of the avatar, make an request to our API using their saved features.

Response Object


On successful requests, the response object will contain information about the generated avatar. This includes the format of the image and the generated avatar.

If an error occured instead, neither the format or avatar will be returned.

Field Data Type Description
format String The format of the generated image: PNG
avatar String A Base64 string representation of the generated avatar

API Response Codes


Unsuccessful requests will return an error code. Please refer to the table below concerning HTTP Status codes.

HTTP Status Code Error code Description
200 - Avatar generated successfully
401 K001 API key not provided
400 K002 Invalid avatar feature provided
400 K003 Avatar gender is required
400 K005 API request url is invalid
401 T007 API key provided is invalid
403 T010 A feature requires an upgraded tier
403 T011 Client's domain not allowed
403 T013 API key has been disabled
429 T015 API key has reached daily quota
500 H009 Internal server error

APIs

Male Avatar API


Available male features

The features for the male avatar are optional — but required to generate the desired avatar outcome. Premium features requires a paid [tier] API key.

Feature Options Tags
head_shape
  • round
  • square
  • diamond
  • heart
  • <optional>
  • <default>
hair_type
  • straight
  • curly
  • wavy
  • spiky
  • shaggy
  • <optional>
  • <default>
hair_length
  • short
  • high
  • long
  • <optional>
  • <default>
hair_style
  • regular_front
  • crew
  • regular_back
  • afro_blow_out
  • blow_out
  • bowl_cut
  • <optional>
  • <default>
alt_hair_style
  • bald
  • buzz_cut
  • <optional>
  • <default>
hair_color
  • blond
  • chestnut
  • dark_blond
  • ginger_red
  • black
  • dark_brown
  • <optional>
  • <default>
eye_color
  • blue
  • gray
  • light_brown
  • dark_brown
  • green
  • hazel
  • <optional>
  • <default>
glasses
  • modern
  • round
  • square
  • <optional>
  • <premium>
beard
  • true
  • false
  • <optional>
  • <premium>
moustache
  • true
  • false
  • <optional>
  • <premium>
goatee
  • true
  • false
  • <optional>
  • <premium>
body_type
  • generic
  • <optional>
  • <default>
skin_tone
  • light
  • pale
  • olive
  • dark
  • neutral
  • <optional>
  • <default>

Default male features

The <default> male avatar feature(s) will be used for the ones not supplied. Please supply all the required features, in each API request, to generate the desired male avatar outcome.

The following avatar features are not generated unless explicitly supplied:

  • glasses
  • beard
  • moustache
  • goatee

Available male hair combinations

You can generate any of the following male hair styles using the combinations below. For specific hair colors, use the hair_color feature (see above).

Showing the list of valid male hair combinations
Image Combination
Image showing avatar hair with options: spiky, high, regular_back hair_type: "spiky",
hair_length: "high",
hair_style: "regular_back"
Image showing avatar hair with options: curly, long, afro_blow_out hair_type: "curly",
hair_length: "long",
hair_style: "afro_blow_out"
Image showing avatar hair with options: wavy, long, blow_out hair_type: "wavy",
hair_length: "long",
hair_style: "blow_out"
Image showing avatar hair with options: curly, short, afro_blow_out hair_type: "curly",
hair_length: "short",
hair_style: "afro_blow_out"
Image showing avatar hair with options: straight, short, blow_out hair_type: "straight",
hair_length: "short",
hair_style: "blow_out"
Image showing avatar hair with options: straight, short, bowl_cut hair_type: "straight",
hair_length: "short",
hair_style: "bowl_cut"
Image showing avatar hair with options: straight, short, crew hair_type: "straight",
hair_length: "short",
hair_style: "crew"
Image showing avatar hair with options: shaggy, short, regular_back hair_type: "shaggy",
hair_length: "short",
hair_style: "regular_back"
Image showing avatar hair with options: spiky, short, regular_back hair_type: "spiky",
hair_length: "short",
hair_style: "regular_back"
Image showing avatar hair with options: curly, short, regular_front hair_type: "curly",
hair_length: "short",
hair_style: "regular_front"
Image showing avatar hair with options: shaggy, short, regular_front hair_type: "shaggy",
hair_length: "short",
hair_style: "regular_front"
Image showing avatar hair with options: spiky, short, regular_front hair_type: "spiky",
hair_length: "short",
hair_style: "regular_front"
Image showing avatar hair with options: straight, short, regular_front hair_type: "straight",
hair_length: "short",
hair_style: "regular_front"
Image showing avatar hair with options: wavy, short, regular_front hair_type: "wavy",
hair_length: "short",
hair_style: "regular_front"

Alternative male hair styles

The alt_hair_style feature will result in a male avatar with very little to no hair (based on selected option). When supplied, the following hair features will be ignored:

  • hair_type
  • hair_length
  • hair_style

Example of a generated male avatar

Image of generated male avatar

Female Avatar API


Available female features

The features for the female avatar are optional — but required to generate the desired avatar outcome. Premium features requires a paid [tier] API key.

Feature Options Tags
head_shape
  • round
  • square
  • diamond
  • heart
  • <optional>
  • <default>
hair_type
  • straight
  • curly
  • wavy
  • <optional>
  • <default>
hair_length
  • short
  • shoulder
  • hip
  • <optional>
  • <default>
hair_style
  • pony_tail
  • pixie_cut
  • afro_blow_out
  • bob_cut
  • blow_out
  • shaggy
  • <optional>
  • <default>
alt_hair_style
  • bald
  • buzz_cut
  • <optional>
  • <default>
hair_color
  • blond
  • chestnut
  • dark_blond
  • ginger_red
  • black
  • dark_brown
  • <optional>
  • <default>
eye_color
  • blue
  • gray
  • light_brown
  • dark_brown
  • green
  • hazel
  • <optional>
  • <default>
glasses
  • modern
  • round
  • square
  • <optional>
  • <premium>
bangs
  • true
  • false
  • <optional>
  • <premium>
body_type
  • generic
  • <optional>
  • <default>
skin_tone
  • light
  • pale
  • olive
  • dark
  • neutral
  • <optional>
  • <default>

Default female features

The <default> female avatar feature(s) will be used for the ones not supplied. Please supply all the required features, in each API request, to generate the desired female avatar outcome.

The following avatar features are not generated unless explicitly supplied:

  • glasses
  • bangs

Available femlae hair combinations

You can generate any of the following female hair styles using the combinations below. For specific hair colors, use the hair_color feature (see above).

Showing the list of valid female hair combinations
Image Combination
Image showing avatar hair with options: curly, hip, afro_blow_out hair_type: "curly",
hair_length: "hip",
hair_style: "afro_blow_out"
Image showing avatar hair with options: curly, shoulder, afro_blow_out hair_type: "curly",
hair_length: "shoulder",
hair_style: "afro_blow_out"
Image showing avatar hair with options: curly, shoulder, blow_out hair_type: "curly",
hair_length: "shoulder",
hair_style: "blow_out" ,
bangs: "true"
Image showing avatar hair with options: curly, short, shaggy hair_type: "curly",
hair_length: "short",
hair_style: "shaggy" ,
bangs: "true"
Image showing avatar hair with options: straight, hip, blow_out hair_type: "straight",
hair_length: "hip",
hair_style: "blow_out"
Image showing avatar hair with options: straight, hip, blow_out hair_type: "straight",
hair_length: "hip",
hair_style: "blow_out" ,
bangs: "true"
Image showing avatar hair with options: straight, short, blow_out hair_type: "straight",
hair_length: "short",
hair_style: "blow_out"
Image showing avatar hair with options: straight, shoulder, blow_out hair_type: "straight",
hair_length: "shoulder",
hair_style: "blow_out"
Image showing avatar hair with options: straight, shoulder, blow_out hair_type: "straight",
hair_length: "shoulder",
hair_style: "blow_out" ,
bangs: "true"
Image showing avatar hair with options: straight, short, bob_cut hair_type: "straight",
hair_length: "short",
hair_style: "bob_cut" ,
bangs: "true"
Image showing avatar hair with options: straight, shoulder, bob_cut hair_type: "straight",
hair_length: "shoulder",
hair_style: "bob_cut" ,
bangs: "true"
Image showing avatar hair with options: straight, short, pixie_cut hair_type: "straight",
hair_length: "short",
hair_style: "pixie_cut" ,
bangs: "true"
Image showing avatar hair with options: straight, hip, pony_tail hair_type: "straight",
hair_length: "hip",
hair_style: "pony_tail"
Image showing avatar hair with options: straight, short, pony_tail hair_type: "straight",
hair_length: "short",
hair_style: "pony_tail" ,
bangs: "true"
Image showing avatar hair with options: wavy, shoulder, blow_out hair_type: "wavy",
hair_length: "shoulder",
hair_style: "blow_out"
Image showing avatar hair with options: wavy, hip, pony_tail hair_type: "wavy",
hair_length: "hip",
hair_style: "pony_tail" ,
bangs: "true"
Image showing avatar hair with options: wavy, short, shaggy hair_type: "wavy",
hair_length: "short",
hair_style: "shaggy" ,
bangs: "true"

Alternative female hair styles

The alt_hair_style feature will result in a female avatar with very little to no hair (based on selected option). When supplied, the following hair features will be ignored:

  • hair_type
  • hair_length
  • hair_style

Example of a generated female avatar

Image of generated female avatar

Random Avatar API


Available random features

The gender feature is required for the random avatar API. An avatar of the specified gender will be randomly generated. Premium features requires a paid [tier] API key.

M = male and F = female
Feature Options Tags
gender
  • male
  • female
  • <required>
use_glasses [M|F]
  • true
  • false
  • random
  • <optional>
  • <default>
  • <premium>
use_beard [M]
  • true
  • false
  • random
  • <optional>
  • <default>
  • <premium>
use_moustache [M]
  • true
  • false
  • random
  • <optional>
  • <default>
  • <premium>
use_goatee [M]
  • true
  • false
  • random
  • <optional>
  • <default>
  • <premium>
use_bangs [F]
  • true
  • false
  • random
  • <optional>
  • <default>
  • <premium>
use_all_features [M|F]
  • true
  • false
  • random
  • <optional>
  • <default>
  • <premium>

Default random features

The <default> random avatar feature(s) are set to false. To ensure the inclusion of a given feature, set it to true in the API request. To allow for random inclusion of a given feature, set it to random.

The use_all_features feature will override all other use_* ones. Please also note that setting a feature to true for the incorrect gender will return an error.

Examples (writing the code)


It is easy to make requests to our API. The following examples will demonstrate how to do this using JavaScript and Python. However, the same approach can be used with most languages.

JavaScript

Example showing how to use the female avatar API.

// JavaScript (jQuery) example
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://avatargen.io/api/generator/female",
  "method": "POST",
  "headers": {
      "content-type": "application/x-www-form-urlencoded",
      "cache-control": "no-cache",
      "apiKey": "MY_API_KEY"
  },
  "data": { // user chose female options
      "skin_tone": "light",
      "head_shape": "diamond",
      "hair_length": "short",
      "hair_type": "straight",
      "hair_style": "blow_out",
      "hair_color": "blond",
      "eye_color": "blue",
      "body_type": "generic"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response.format); // >> "PNG"
  console.log(response.avatar); // >> "data:image/png;base64,somechars=="
  // $("img").attr("src", response.avatar);
});

Python

Example showing how to use the male avatar API.

# Python 3 (http.client)
import http.client
import json

data = { # user chose male options
  "skin_tone": "light",
  "head_shape": "diamond",
  "hair_length": "short",
  "hair_style": "afro_blow_out",
  "hair_type": "curly",
  "hair_color": "blond",
  "eye_color": "blue",
  "body_type": "generic"
}
payload = json.dumps(data)

headers = {
  "content-type": "application/json; charset=utf-8",
  "cache-control": "no-cache",
  "apiKey": "MY_API_KEY"
}

conn = http.client.HTTPSConnection("avatargen.io")
conn.request("POST", "/api/generator/male", payload, headers)
res = conn.getresponse()
data = res.read()

res = json.loads(data.decode("utf-8"))
print(res["format"]) # >> "PNG"
print(res["avatar"]) # >> "data:image/png;base64,somechars=="

Resources

Avatar Assets


AvatarGen.io assests are designed to work with our API service. The provided assets can be imported into your project and used programatically. Don't want to type the features and options by hand? Check out our asset repository.

They are open sourced (MIT) and currently in beta. Drastic changes are to be expected.

Get the assets | Usage | GitHub

Share The Love


We're into backlinks! If you're on our free tier, please support us by using one of the following HTML backlink code.

Text Backlink

Powered by <a href="https://avatargen.io/" title="Avatar Generator API">AvatarGen.io</a>

Powered by AvatarGen.io

Image Backlink

<a href="https://avatargen.io/" title="Avatar Generator API"><img src="//cdn.avatargen.io/icons/AvatarGen_logo.png" width="250px" alt="AvatarGen.io Logo" border="0"></a>

AvatarGen.io Logo

Join Our Community


Stay up to date with AvatarGen.io and reach out to the community with these helpful resources.

Thank you for visiting AvatarGen.io. We use cookies to deliver our services. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.