Start with Avatars_
Get started quickly with Appwrite Avatars. Learn how to generate user initials, QR codes, and other avatar images in minutes.
1 min read
You can start using Appwrite Avatars immediately. The service is publicly accessible and does not require authentication or API keys.
Initialize the client
First, initialize the Appwrite client with your project endpoint and project ID.
import { Client, Avatars } from "appwrite";
const client = new Client() .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') .setProject('<PROJECT_ID>');
const avatars = new Avatars(client);Generate user initials
Generate an avatar image from a user's name or initials. This is useful for displaying user profiles when no profile picture is available.
const result = avatars.getInitials({ name: 'John Doe', width: 200, height: 200, background: '000000'});
console.log(result); // Resource URLGenerate QR code
Create a QR code from any text string. This is commonly used for two-factor authentication, sharing links, or encoding data.
const result = avatars.getQR({ text: 'https://example.com', size: 300, margin: 1, download: false});
console.log(result); // Resource URLGet country flag
Retrieve a country flag icon by country code. This is useful for displaying user locations or regional information.
import { Flag } from "appwrite";
const result = avatars.getFlag({ code: Flag.UnitedStates, width: 100, height: 100});
console.log(result); // Resource URLNext steps
Now that you've generated your first avatars, explore more advanced features:
- Show profile pictures with user photos
- Learn about user initials customization
- Discover QR code options
- Explore image manipulation capabilities
Was this page helpful?
Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.