Playground API
DocsStatsBlogStudio
Documentation Tree
Technical BlogFeature Deep Dives
  • Introduction
  • Quickstart
    5 min
  • How It Works
  • Recipes & Cookbooks
  • Platform Comparisons
  • Real-World Showcase
  • Interactive Studio
    Studio
  • GraphiQL IDE
    IDE
  • Session Quotas & Activity
  • Network Chaos Simulator
  • Atomic Sandbox Reset
  • Overview & Models
    Hub
  • Users Resource
  • Posts Resource
  • Comments Resource
  • Todos Resource
  • Custom Collections
    Custom
  • Multipart File Uploads
    Upload
  • Dynamic SVG Avatars
    SVG
  • Image Thumbnails
    CDN
  • Relational Filtering
  • Full-Text Search
  • Dynamic Sorting
  • Offset Pagination
  • Cursor Pagination
    Scroll
  • CSV & Excel Export & Import
    IO
  • Custom Collections
    CRUD
  • Overview & Architecture
    Hub
  • JWT Auth Flow
  • Refresh Token Rotation
    Mutex
  • RBAC Permission Matrix
    Roles
  • Expiry Simulation
  • Clock Skew Drift
  • Password Recovery Loop
  • Dual-Mode Sandboxing
  • GraphiQL IDE
    IDE
  • Relational Queries
  • Stateful Mutations
  • Realtime Subscriptions
  • Overview & Flowcharts
    Hub
  • Hosted Checkout
    Stripe
  • Payment Intents API
  • 3DS Challenge Modal
    Modal
  • Customers Vault
  • Charges & Refunds
  • Test Cards Catalog
  • Overview & Channels
    Hub
  • Virtual Email Mailbox
    Mailtrap
  • Virtual SMS Terminal
    Phone
  • In-App Notifications
  • Message Dispatcher
  • Realtime Studio
    Studio
  • Native WebSocket (/ws)
  • Socket.io Gateway
  • Presence & Echo Bot
  • Server-Sent Events (SSE)
    SSE
  • Analytics Telemetry
  • Webhook Subscriptions
  • HMAC SHA-256 Signatures
  • Delivery Logs
  • Manual Retry Simulator
  • Network Latency Delay
  • HTTP Status Codes
  • Rate-Limit Simulator
    429
  • Flaky Network & Jitter
    Chaos
  • Session Quotas & Activity
  • JSON Snapshots
    JSON
  • Headless CI/CD Testing
    CI
  • Mobile QR Code Sync
  • System Metrics & Health
  • Atomic Sandbox Reset
  • Official TypeScript SDK
  • Multi-Language Generators
  • DevTools Extension
  • OpenAPI 3.1 Spec
    JSON
  • Postman Collection v2.1
  • Bruno Collection
  • Insomnia Workspace
  • TypeScript .d.ts
    .d.ts
  • AI Prompt Rules
    Rules
  • Context Index (llms.txt)
  • Full Schema (llms-full.txt)
  • Manifest (product.json)
  • All Feature Articles
    Blog
  • React CRUD Without Backend
    Deep Dive
  • Why Static APIs Fail
  • Mocking Stateful Auth
  • WebSockets & SSE Guide
Technical Blog
Articles

In-depth articles explaining stateful mock APIs, WebSockets, payments, and frontend resilience.

Read Articles
PreviousMultipart File Uploads
NextImage Thumbnails
Media & Binary Assets

Deterministic Dynamic SVG Avatars

Zero-dependency, infinite-resolution vector avatars generated deterministically from any username, email, or user ID. Features 12 curated modern gradients, intelligent initials parsing, dynamic squircle or circle clipping, and 1-year immutable CDN caching.

100% Vector SVG (Zero Pixelation)12 Curated Gradient PalettesSmart Initials ExtractionImmutable 1-Year CDN Cache

Live Vector Avatar Studio

Customize seed, dimensions, and shape to preview the dynamically generated vector SVG in real-time.

GET /api/v1/avatars/:seed.svg
Avatar for Bret128 × 128px

Seed: "Bret"

Shape: Circular (rx=size/2)

Quick Test Personas & Formats:
Avatar Resolution: 128 × 128 pixels
https://playground.nileslabs.com/api/v1/avatars/Bret.svg?size=128&rounded=true

12 Curated Deterministic Gradient Palettes

The backend hashes the seed string into an integer to select from 12 accessible, modern linear gradients. Click any palette to load its matching seed into the studio.

Initials Parsing Algorithm & XML Sanitization

How Playground API safely extracts clean initials while eliminating vector injection and XSS vulnerabilities.

Token Extraction Rules

Input SeedExtracted InitialsParsing Logic
Leanne GrahamLGFirst char of first & second word
user-alex-turnerUAHyphen/underscore separated tokens
bretBRFirst two letters of single word
ZZSingle letter fallback
***PAPlayground Avatar default fallback

SVG Injection & Caching Architecture

Every rendered initial character undergoes strict XML entity escaping via escapeXml() to eliminate SVG tag breakout and stored XSS vectors.

Immutable CDN Cache Headers:
Cache-Control: public, max-age=86400, s-maxage=31536000, stale-while-revalidate

In-memory LRU cache stores up to 1,000 recently generated SVGs on the server, serving repeated requests in under 1 millisecond.

Interactive Avatar API Consoles

Execute direct HTTP requests to test responses and raw SVG XML payloads:

Fetch Raw Vector SVG

Fetches raw SVG image data with Content-Type: image/svg+xml.

GET
response.json
1
{
2
// Click "Send" above to execute this request against the live server.
3
}

Generate Custom Squircle Avatar

Fetches a 256px squircle avatar with explicit .svg extension.

GET
response.json
1
{
2
// Click "Send" above to execute this request against the live server.
3
}

Production Client Integration Recipes

Ready-to-use snippets for React components, Tailwind avatar stacks, TypeScript helpers, and direct HTML:

1
// Reusable React / Next.js UserAvatar Component
2
import React, { useState } from 'react';
3
4
interface UserAvatarProps {
5
seed: string;
6
size?: number;
7
rounded?: boolean;
8
className?: string;
9
alt?: string;
10
}
11
12
export function UserAvatar({
13
seed,
14
size = 48,
15
rounded = true,
16
className = '',
17
alt = 'User Avatar',
18
}: UserAvatarProps) {
19
const [hasError, setHasError] = useState(false);
20
21
// Explicit .svg extension ensures clean rendering in all image tags and SSR
22
const avatarUrl = https://playground.nileslabs.com/api/v1/avatars/${encodeURIComponent(
23
seed
24
)}.svg?size=${size}&rounded=${rounded};
25
26
return (
27
<img
28
src={hasError ? '/fallback-avatar.png' : avatarUrl}
29
alt={alt}
30
width={size}
31
height={size}
32
onError={() => setHasError(true)}
33
loading="lazy"
34
decoding="async"
35
className={inline-block shrink-0 object-contain ${
36
rounded ? 'rounded-full' : 'rounded-2xl'
37
} ${className}}
38
/>
39
);
40
}
Next in Media

Landscape Thumbnails & Transformations

Generate 16:9 placeholder banners with dynamic multiline word wrapping and dimension badges.

Previous

Multipart File Uploads

Test single and bulk multipart uploads with real Cloudinary CDN delivery and magic byte validation.