The user initials endpoint generates avatar images from names or initials. This is particularly useful for displaying user profiles when no profile picture is available, creating a consistent visual identity across your application.
Generate initials
Generate an avatar image from a user's name. The service automatically extracts initials from the name and displays them on a colored background.
Parameters
The getInitials method accepts the following parameters:
| Parameter | Type | Description |
name | string | The name to generate initials from. The service extracts the first letter of each word. |
width | integer | The width of the output image in pixels. Accepts values between 0-2000. |
height | integer | The height of the output image in pixels. Accepts values between 0-2000. |
background | string | The background color in hexadecimal format without the leading #. Defaults to a random color if not provided. |
Customization
You can customize the appearance of the initials avatar by adjusting the dimensions and background color. The service automatically selects appropriate text color based on the background for optimal contrast.
Use cases
User initials avatars are commonly used in:
- User profiles: Display avatars in user lists, comments, and profile pages when no profile picture is available
- Team members: Show team member avatars in collaboration interfaces
- Notifications: Display sender avatars in notification systems
- Activity feeds: Show user avatars in activity and timeline views