The backend of the avatarMaker can be queried using a REST API. The entry point for every call is always avatarmaker.php
and it accepts both GET
and POST
requests.
The avatarMaker can be used as a drop-in replacement for gravatar identicons or similar services. This function can be especially useful in blogs and social websites.
Using a simple GET request the backend will generate an avatar based on the provided md5 hash.
The format of the call is the following:
Parameter | Type | Notes |
---|---|---|
SIZE Optional |
Integer [0-1024] |
The size of the rendered avatar, this parameter is optional and if missing the default 1024px will be used |
HASH | String |
The md5 hash to generate the avatar. If an invalid hash is supplied, the API will answer with a 404 error |
yoursite.tld/UPLOADFOLDER/avatarmaker.php?size=[SIZE]&md5=[HASH]
Warning
For a given hash, the API will answer always with the same avatar, but if the content of the assets folder is changed, the generated avatar for the same hash will change!
You can load an avatar with a simple GET request, just like loading a normal image.
There are three GET parameters that control items, colors, and size of the avatar.
Parameter | Type | Notes |
---|---|---|
SIZE Optional |
Integer [0-1024] |
The size of the rendered avatar, this parameter is optional and if missing the default 1024px will be used |
avm_items | The key/value list of the items that compose the avatar. The keys are the names of the layers and the values are the names if the selected items in that category. | |
avm_colors | The key/value list of the colors for each palette |
avm_items
needs to be encoded in a specific format to work properly. Keys and values must be sepated by :
and between each pair you must place a |
.
layer1:itemname1|layer2:itemname2
avm_colors
follows the same rules as avm_items
but in this case the values must be hex encoded colors. To avoid errors #
must be replaced with 0x
like in the example below.
color1:0xffffff|color2:0xffffff
This is an example call to the API:
yoursite.tld/UPLOADFOLDER/avatarmaker.php?size=1024&avm_items=background:background_1|head:face_1|ears:ears_1|eyebrows:eyebrows_3|eyes:eyes_2|hair:hair_4|mouth:mouth_3|nose:nose_2&avm_colors=background:0x124d32|skin:0xD18A67|hair:0x815128
This is another way of generating the avatar and is equivalent the GET query string. It has the advantage of being able to generate the avatar from a JSON object without requiring to encode it.
It may be faster and easier to use in certain contexts.
The JSON object must be serialized and sent as the payload of a POST request. The generated avatar will be sent as a response.
An example of the JSON object is the following:
{
"size":1024,
"layers":{
"background": "background_4",
"ears":"ears_1",
"head":"face_1",
"eyebrows":"eyebrows_1",
"eyes":"eyes_2",
"nose":"nose_2",
"mouth":"mouth_5",
"hair":"hair_8",
"objects":"a_0"
},
"colors":{
"background":"#A2B4EE",
"skin":"#EFC0A4",
"hair":"#FFD900",
"objects":"#1267df"
}
}
Parameter | Type | Notes |
---|---|---|
size Optional |
Integer [0-1024] |
The size of the rendered avatar, this parameter is optional and if missing the default 1024px will be used |
layers | Object |
An object holding all layers as keys with the name of the selected item in the category as value |
colors | Object |
An object holding all palettesIDs as keys with the corresponding color, hex encoded, as values |