API Documentation
We made it very simple to incorporate personalized avatars into your apps and websites.
We made it very simple to incorporate personalized avatars into your apps and websites.
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.
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.
apiKey=YOUR-API-KEY
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
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.
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.
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.
Your API key has a daily request quota — design your user-flow to best utilize the number of requests available.
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 |
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 |
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 |
|
|
hair_type |
|
|
hair_length |
|
|
hair_style |
|
|
alt_hair_style |
|
|
hair_color |
|
|
eye_color |
|
|
glasses |
|
|
beard |
|
|
moustache |
|
|
goatee |
|
|
body_type |
|
|
skin_tone |
|
|
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
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).
Image | Combination |
---|---|
hair_type : "spiky",hair_length : "high",hair_style : "regular_back"
|
|
hair_type : "curly",hair_length : "long",hair_style : "afro_blow_out"
|
|
hair_type : "wavy",hair_length : "long",hair_style : "blow_out"
|
|
hair_type : "curly",hair_length : "short",hair_style : "afro_blow_out"
|
|
hair_type : "straight",hair_length : "short",hair_style : "blow_out"
|
|
hair_type : "straight",hair_length : "short",hair_style : "bowl_cut"
|
|
hair_type : "straight",hair_length : "short",hair_style : "crew"
|
|
hair_type : "shaggy",hair_length : "short",hair_style : "regular_back"
|
|
hair_type : "spiky",hair_length : "short",hair_style : "regular_back"
|
|
hair_type : "curly",hair_length : "short",hair_style : "regular_front"
|
|
hair_type : "shaggy",hair_length : "short",hair_style : "regular_front"
|
|
hair_type : "spiky",hair_length : "short",hair_style : "regular_front"
|
|
hair_type : "straight",hair_length : "short",hair_style : "regular_front"
|
|
hair_type : "wavy",hair_length : "short",hair_style : "regular_front"
|
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
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 |
|
|
hair_type |
|
|
hair_length |
|
|
hair_style |
|
|
alt_hair_style |
|
|
hair_color |
|
|
eye_color |
|
|
glasses |
|
|
bangs |
|
|
body_type |
|
|
skin_tone |
|
|
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
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).
Image | Combination |
---|---|
hair_type : "curly",hair_length : "hip",hair_style : "afro_blow_out"
|
|
hair_type : "curly",hair_length : "shoulder",hair_style : "afro_blow_out"
|
|
hair_type : "curly",hair_length : "shoulder",hair_style : "blow_out"
,bangs : "true"
|
|
hair_type : "curly",hair_length : "short",hair_style : "shaggy"
,bangs : "true"
|
|
hair_type : "straight",hair_length : "hip",hair_style : "blow_out"
|
|
hair_type : "straight",hair_length : "hip",hair_style : "blow_out"
,bangs : "true"
|
|
hair_type : "straight",hair_length : "short",hair_style : "blow_out"
|
|
hair_type : "straight",hair_length : "shoulder",hair_style : "blow_out"
|
|
hair_type : "straight",hair_length : "shoulder",hair_style : "blow_out"
,bangs : "true"
|
|
hair_type : "straight",hair_length : "short",hair_style : "bob_cut"
,bangs : "true"
|
|
hair_type : "straight",hair_length : "shoulder",hair_style : "bob_cut"
,bangs : "true"
|
|
hair_type : "straight",hair_length : "short",hair_style : "pixie_cut"
,bangs : "true"
|
|
hair_type : "straight",hair_length : "hip",hair_style : "pony_tail"
|
|
hair_type : "straight",hair_length : "short",hair_style : "pony_tail"
,bangs : "true"
|
|
hair_type : "wavy",hair_length : "shoulder",hair_style : "blow_out"
|
|
hair_type : "wavy",hair_length : "hip",hair_style : "pony_tail"
,bangs : "true"
|
|
hair_type : "wavy",hair_length : "short",hair_style : "shaggy"
,bangs : "true"
|
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
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.
Feature | Options | Tags |
---|---|---|
gender |
|
|
use_glasses [M|F] |
|
|
use_beard [M] |
|
|
use_moustache [M] |
|
|
use_goatee [M] |
|
|
use_bangs [F] |
|
|
use_all_features [M|F] |
|
|
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.
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.
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);
});
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=="
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.
We're into backlinks! If you're on our free tier, please support us by using one of the following HTML backlink code.
Powered by <a href="https://avatargen.io/" title="Avatar Generator API">AvatarGen.io</a>
<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>
Stay up to date with AvatarGen.io and reach out to the community with these helpful resources.