Quick Start
🚀 Generate Your First Avatar
Make a simple POST request to render an avatar with your desired settings. The API returns a PNG image or base64 data.
// Request
POST https://api.squarefacegenerator.net/v1/render
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"skin": "#F2C9A0",
"hairStyle": 3,
"hairColor": "#232946",
"eyeStyle": 2,
"bg": "transparent",
"size": 512
}
// Response
{
"success": true,
"image": "data:image/png;base64,iVBORw0KGgo...",
"url": "https://cdn.squarefacegenerator.net/renders/abc123.png",
"expiresAt": "2025-01-01T12:10:00Z"
}
Authentication
🔐 API Keys
All API requests require authentication via a Bearer token in the Authorization header. API keys are tied to your account and can be managed from your dashboard.
Authorization: Bearer sk_live_abc123def456...
Important: Keep your API keys secret. Never expose them in client-side code or public repositories.
Endpoints
Generate a single avatar with custom parameters. Returns a PNG image as base64 or a temporary URL.
Parameters
| Name | Type | Description |
|---|---|---|
| skin | string optional | Hex color for skin tone (e.g., "#F2C9A0") |
| hairStyle | integer optional | Hair style ID (1-20). Use /v1/options for available styles. |
| hairColor | string optional | Hex color for hair (e.g., "#232946") |
| eyeStyle | integer optional | Eye style ID (1-15) |
| expression | string optional | Expression: "happy", "sad", "surprised", "neutral" |
| accessories | array optional | Array of accessory IDs to apply |
| bg | string optional | "transparent" or hex color (default: "#FFFFFF") |
| size | integer optional | Output size: 64, 128, 256, 512, or 1024 (default: 256) |
| format | string optional | "base64" or "url" (default: "base64") |
Example Response
{
"success": true,
"image": "data:image/png;base64,...",
"url": "https://cdn.squarefacegenerator.net/renders/xyz.png",
"expiresAt": "2025-01-01T12:10:00Z",
"renderTime": 142
}
Generate multiple avatars in a single request. More efficient for bulk generation. Maximum 50 avatars per request.
// Request body
{
"avatars": [
{ "hairStyle": 1, "skin": "#F2C9A0" },
{ "hairStyle": 5, "skin": "#8D5524" },
{ "hairStyle": 12, "skin": "#FFDBAC" }
],
"size": 256,
"format": "url"
}
Generate a completely random avatar. Great for placeholder avatars or inspiration.
GET /v1/random?size=512&format=url
Get available style presets (anime, kawaii, pixel, chibi, retro). Apply a preset by ID for quick styling.
// Response
{
"presets": [
{ "id": "anime", "name": "Anime Style", ... },
{ "id": "kawaii", "name": "Kawaii Cute", ... },
{ "id": "pixel", "name": "Pixel Art", ... }
]
}
Get all available customization options with their IDs. Use these IDs when making render requests.
API Pricing
Starter
- ✓ All render endpoints
- ✓ Up to 512px exports
- ✓ Email support
- ✓ Standard rate limits
Growth
- ✓ Everything in Starter
- ✓ 1024px HD exports
- ✓ Priority support
- ✓ Higher rate limits
Enterprise
- ✓ Everything in Growth
- ✓ Custom SLA
- ✓ Dedicated support
- ✓ Custom integrations
SDKs & Libraries
JavaScript
npm install squareface
Coming SoonPython
pip install squareface
Coming SoonRuby
gem install squareface
PlannedGo
go get squareface
PlannedSDK Code Examples
🟨 JavaScript / Node.js
Install the SDK and generate avatars with just a few lines of code.
// Installation
npm install squareface
// or
yarn add squareface
// Basic Usage
import { SquareFace } from 'squareface';
// Initialize with your API key
const client = new SquareFace('sk_live_your_api_key');
// Generate a single avatar
const avatar = await client.render({
skin: '#F2C9A0',
hairStyle: 3,
hairColor: '#232946',
eyeStyle: 2,
size: 512,
bg: 'transparent'
});
console.log(avatar.url); // CDN URL for the avatar
console.log(avatar.image); // Base64 image data
// Generate random avatar
const randomAvatar = await client.random({ size: 256 });
// Batch generation for Discord bots
const avatars = await client.batch([
{ hairStyle: 1, skin: '#F2C9A0' },
{ hairStyle: 5, skin: '#8D5524' },
{ hairStyle: 12, skin: '#FFDBAC' }
], { size: 128 });
// Use with preset styles
const animeAvatar = await client.render({
preset: 'anime',
hairColor: '#FF69B4'
});
// Discord.js Integration Example
import { Client } from 'discord.js';
import { SquareFace } from 'squareface';
const bot = new Client({ intents: [...] });
const sf = new SquareFace(process.env.SQUAREFACE_KEY);
bot.on('messageCreate', async (msg) => {
if (msg.content === '!avatar') {
const avatar = await sf.random({ size: 256 });
msg.reply({ files: [avatar.url] });
}
});
🐍 Python
Python SDK with async support for high-performance applications.
# Installation
pip install squareface
# or with async support
pip install squareface[async]
# Basic Usage
from squareface import SquareFace
# Initialize client
client = SquareFace("sk_live_your_api_key")
# Generate a single avatar
avatar = client.render(
skin="#F2C9A0",
hair_style=3,
hair_color="#232946",
eye_style=2,
size=512,
bg="transparent"
)
print(avatar.url) # CDN URL
avatar.save("my_avatar.png") # Save to file
# Generate random avatar
random_avatar = client.random(size=256)
# Batch generation
avatars = client.batch([
{"hair_style": 1, "skin": "#F2C9A0"},
{"hair_style": 5, "skin": "#8D5524"},
{"hair_style": 12, "skin": "#FFDBAC"}
], size=128)
# Save all avatars
for i, av in enumerate(avatars):
av.save(f"avatar_{i}.png")
# Async Usage (for web apps like FastAPI)
from squareface import AsyncSquareFace
from fastapi import FastAPI
from fastapi.responses import Response
app = FastAPI()
sf = AsyncSquareFace("sk_live_your_api_key")
@app.get("/avatar")
async def generate_avatar():
avatar = await sf.random(size=256)
return {"url": avatar.url}
@app.get("/avatar/image")
async def get_avatar_image():
avatar = await sf.random(size=256)
return Response(
content=avatar.bytes,
media_type="image/png"
)
🔧 cURL / REST API
Direct HTTP requests for any language or platform.
# Generate a single avatar
curl -X POST https://api.squarefacegenerator.net/v1/render \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"skin": "#F2C9A0",
"hairStyle": 3,
"hairColor": "#232946",
"size": 512,
"bg": "transparent"
}'
# Generate random avatar
curl https://api.squarefacegenerator.net/v1/random?size=256 \
-H "Authorization: Bearer sk_live_your_api_key"
# Get available options
curl https://api.squarefacegenerator.net/v1/options \
-H "Authorization: Bearer sk_live_your_api_key"
Rate Limits
📊 Request Limits
To ensure fair usage and service stability, the API enforces rate limits based on your plan:
| Plan | Requests/Minute | Requests/Day | Concurrent |
|---|---|---|---|
| Starter | 30 | 2,500 | 5 |
| Growth | 60 | 10,000 | 10 |
| Enterprise | Custom | Unlimited | Custom |
Rate limit headers are included in all responses: X-RateLimit-Remaining, X-RateLimit-Reset
Ready to Get Started?
Request early access to the API. We'll notify you when it's ready and provide priority onboarding.
Request API Access →