Avatar Generator API
Default profile pictures from a name: initials avatars that read Vietnamese names correctly (Nguyễn Văn An → NA) or identicons, with a stable colour per user.
The avatar API draws a default profile picture for users who have not uploaded one. style=initials (default) writes the initials on a coloured circle, square or rounded square. Vietnamese names put the given name last, so the initials are the first letter of the family name and of the given name (Nguyễn Văn An → NA, Đặng Thị Ánh → ĐÁ, with accents preserved); length=1 keeps only the given name and initials= sets them yourself.
style=identicon draws a symmetric 5×5 pattern, handy for anonymous accounts, API keys or wallet addresses. The colour comes from a hash of the name, so the same user always gets the same avatar on every page, and text switches to dark on light backgrounds for contrast. background and color override the colours.
Initials avatars are SVG (crisp at any size, usable directly in <img src>); identicons are also available as PNG. Use the URL form /v1/avatar/Nguyễn Văn An.svg; responses are cacheable for a week.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
name | query|path | string | yes | Name or any seed (email, id…); or /v1/avatar/{name}.svg. | |
style | query | string | no | initials | initials or identicon. |
size | query | number | no | 128 | Size in px (16–1024). |
shape | query | string | no | circle | circle, square or rounded. |
format | query | string | no | svg | svg, or png (identicon). |
length | query | number | no | 2 | Number of initials (1–3). |
background | query | string | no | Background colour (hex). | |
color | query | string | no | Text / pattern colour (hex). |
Example
curl "https://apibox.io.vn/v1/avatar?name=Nguyễn Văn An&size=128" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o outputconst res = await fetch('https://apibox.io.vn/v1/avatar?name=Nguyễn Văn An&size=128', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const blob = await res.blob();import requests
res = requests.get(
"https://apibox.io.vn/v1/avatar?name=Nguyễn Văn An&size=128",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
open("output", "wb").write(res.content)<?php
$ch = curl_init('https://apibox.io.vn/v1/avatar?name=Nguyễn Văn An&size=128');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
file_put_contents('output', $response);Response
binary image/svg+xml
Use cases
- Default avatars in SaaS apps, forums and comment sections
- Contact lists and chat apps
- Identicons for API keys, devices or anonymous users
- Placeholders in design mock-ups
FAQ
Why “NA” for Nguyễn Văn An?
Vietnamese names are family – middle – given name. Two letters use the family and given names; length=1 shows only the given name (A).
Can I get PNG?
Identicons yes (format=png). Initials are SVG only, because PNG text would need a font renderer; SVG works in all browsers and in <img> tags.
Will the colour change?
No. It is derived from the name (case-insensitive), so it is stable across requests.
Related APIs
QR Code Generator
Generate QR codes as PNG or SVG with one GET request: URLs, text, WiFi logins, vCards, e-mail, SMS, phone and geo links. Custom colours, size and ECC.
|||Barcode Generator
Create Code 128 barcodes for labels, SKUs and shipping with a single request. SVG with human-readable text or PNG, custom height, width and colours.
▭Placeholder Image
Get placeholder images of any size for mockups and tests: /v1/placeholder/600x400.png. SVG with custom text and colours, or a solid-colour PNG.