This repository contains code that uses the REST API to generate avatars and return them as images.
All requests return an image stream to be used directly in an <img/> tag.
Generate an avatar with default settings, for user "John Doe":
https://hono-avatars.pages.dev/?name=john+doe
Generate a blue avatar:
https://hono-avatars.pages.dev/?background=0D8ABC&color=fff
Note: This project is compatible with
ui-avatars.com, some parameters are not supported but should work the same.
background- The background color of the avatar. Default is#DDDDDD.blur- The blur of the avatar. Default is0.bold- The font weight of the text. Default isfalse.border- The border of the avatar. Default isfalse.border-style- The border style of the avatar. Default issolid.border-width- The border width of the avatar. Default is0.5.color- The text color of the avatar. Default is#222222.font-family- The font family of the text. Default issans.font-size- The font size of the text. Default is0.5.format- The format of the image. Default ispng.length- The length of the text. Default is2.name- The name of the user to generate the avatar.oblique- The font style of the text. Default isfalse.opacity- The opacity of the avatar. Default is1.reverse- The reverse of the text. Default isfalse.rotate- The rotation of the text. Default is0.rounded- The border radius of the avatar. Default isfalse.shadow- The text shadow of the text. Default isfalse.size- The size of the avatar. Default is64.uppercase- The text transform of the text. Default istrue.preset- The preset of the avatar. Default isdefault.
Click to expand!
- Description: The background color of the avatar.
- Default:
#DDDDDD - Example:
background=0D8ABC - Values: Any valid hex color code
- Description: The blur of the avatar.
- Default:
0 - Example:
blur=1 - Values: Any integer between
0and1
- Description: The font weight of the text.
- Default:
false - Example:
bold=true - Values:
true,false
- Description: The border of the avatar.
- Default:
false - Example:
border=0D8ABC - Values: Any valid hex color code or
false
- Description: The border style of the avatar.
- Default:
solid - Example:
border-style=dashed - Values:
solid,dashed
- Description: The border width of the avatar.
- Default:
0.5 - Example:
border-width=1 - Values: Any decimal between
0.1and1
- Description: The text color of the avatar.
- Default:
#222222 - Example:
color=fff - Values: Any valid hex color code
- Description: The font family of the text.
- Default:
sans - Example:
font-family=serif - Values:
mono,sans,serif(monois English only)
- Description: The font size of the text.
- Default:
0.5 - Example:
font-size=0.7 - Values: Any decimal between
0.1and1
- Description: The format of the image.
- Default:
png - Example:
format=svg - Values:
png,svg
- Description: The length of the text.
- Default:
2 - Example:
length=full - Values: Any positive integer or
full
- Description: The name of the user to generate the avatar.
- Default: None
- Example:
name=John+Doe - Values: Any string value (max 40 characters)
- Description: The font style of the text.
- Default:
false - Example:
oblique=true - Values:
true,false
- Description: The opacity of the avatar.
- Default:
1 - Example:
opacity=0.5 - Values: Any decimal between
0and1
- Description: The reverse of the text.
- Default:
false - Example:
reverse=true - Values:
true,false
- Description: The rotation of the text.
- Default:
0 - Example:
rotate=45 - Values: Any integer between
-360and360
- Description: The border radius of the avatar.
- Default:
false - Example:
rounded=true - Values:
true,false
- Description: The text shadow of the text.
- Default:
false - Example:
shadow=true - Values:
true,false
- Description: The size of the avatar.
- Default:
64 - Example:
size=128 - Values: Any integer between
16and512
- Description: The text transform of the text.
- Default:
true - Example:
uppercase=false - Values:
true,false
- Description: The preset of the avatar.
- Default:
default - Example:
preset=google - Values:
default,google
This project provides OpenAPI documentation and interactive API testing through Swagger UI.
/- Avatar generation endpoint (main API)/docs- Interactive Swagger UI documentation/openapi.json- OpenAPI specification in JSON format
Once the server is running, you can access the interactive API documentation at:
http://localhost:8787/docs
The Swagger UI provides:
- Complete API documentation with parameter descriptions
- Interactive testing interface - try the API directly from the browser
- Request/response examples
- Parameter validation and type information
The OpenAPI specification is available at:
http://localhost:8787/openapi.json
This JSON file contains the complete API schema and can be used with various OpenAPI tools and clients.
hono-avatars project is licensed under the MIT License.