راهنمای Integration

راهنما

از hashavatar.app مستقیم از browser، frontend یا backend خود استفاده کنید. هر avatar URL deterministic است، پس identifier و options یکسان همیشه خروجی یکسان تولید می‌کنند.

URL پایه

وقتی به یک image URL عمومی ساده نیاز دارید از query endpoint استفاده کنید.

https://hashavatar.app/v1/[email protected]&algorithm=sha512&kind=robot&background=white&accessory=glasses&color=gold&expression=happy&shape=circle&format=webp&size=256

Path Style URL

اگر embed URLs تمیزتر می‌خواهید، از فرم path استفاده کنید.

https://hashavatar.app/avatar/fox/[email protected]/webp

نمونه HTML

<img
  src="https://hashavatar.app/v1/[email protected]&algorithm=sha512&kind=monster&background=themed&accessory=horns&color=crimson&expression=grumpy&shape=hexagon&format=webp&size=256"
  alt="Generated monster avatar"
/>

نمونه JavaScript

const avatarUrl = new URL("https://hashavatar.app/v1/avatar");
avatarUrl.search = new URLSearchParams({
  id: user.email,
  algorithm: "sha512",
  kind: "robot",
  background: "white",
  accessory: "glasses",
  color: "gold",
  expression: "happy",
  shape: "circle",
  format: "webp",
  size: "256",
}).toString();

پارامترهای پشتیبانی‌شده

  • id: any stable identifier such as an email, username, internal user id, or one-way hash
  • tenant: optional namespace partition for multi-tenant apps
  • style_version: optional style namespace such as v2
  • algorithm: identity hash mode; only sha512 is supported
  • kind: any public hashavatar family, including cat, dog, robot, planet, rocket, frog, panda, cupcake, pizza, octopus, knight, bear, penguin, dragon, ninja, astronaut, diamond, coffee-cup, and shield
  • background: themed, white, black, dark, light, transparent, polka-dot, striped, checkerboard, grid, sunrise, ocean, or starry
  • accessory: none, glasses, hat, headphones, crown, bowtie, eyepatch, scarf, halo, or horns
  • color: default, neon-mint, pastel-pink, crimson, gold, or deep-sea-blue
  • expression: default, happy, grumpy, surprised, sleepy, winking, cool, or crying
  • shape: square, circle, squircle, hexagon, or octagon
  • format: output format; only webp is supported
  • size: from 64 up to 1024

لایه‌های accessory و expression برای character-style families اعمال می‌شوند. Object-style families مانند planet، rocket، paws، mushroom، cactus، cupcake، pizza، icecream، diamond، coffee-cup و shield به accessory=none و expression=default نرمال می‌شوند.

لینک‌های ذخیره‌سازی امضاشده

اگر این deployment دارای object storage پیکربندی‌شده باشد، از /v1/avatar/link یک presigned storage link درخواست کنید. این endpoint شیء تولیدشده را ذخیره می‌کند و JSON شامل signed URL، object key و hashed cache key برمی‌گرداند. Avatar responses استاندارد signed-link metadata را در response headers نمایش نمی‌دهند.

GET https://hashavatar.app/v1/avatar/[email protected]&algorithm=sha512&kind=robot&background=white&accessory=glasses&color=gold&expression=happy&shape=circle&format=webp&size=256

Open Source

Source سایت عمومی در API repository است و reusable avatar renderer در crates.io منتشر شده است. مخزن · crates.io