Integration Guide

ជំនួយ

ប្រើ hashavatar.app ដោយផ្ទាល់ពី browser, frontend ឬ backend របស់អ្នក។ avatar URL នីមួយៗ deterministic ដូច្នេះ identifier និង options ដូចគ្នានឹងផ្តល់ output ដូចគ្នាជានិច្ច។

Basic URL

ប្រើ query endpoint នៅពេលអ្នកត្រូវការ public image URL សាមញ្ញ។

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

ប្រើ path form ប្រសិនបើអ្នកចូលចិត្ត embed URLs ដែលស្អាតជាង។

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();

Supported Parameters

  • 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 layers ត្រូវបានអនុវត្តសម្រាប់ character-style families។ Object-style families ដូចជា planet, rocket, paws, mushroom, cactus, cupcake, pizza, icecream, diamond, coffee-cup និង shield ត្រូវបាន normalize ទៅ accessory=none និង expression=default។

Signed Storage Links

ប្រសិនបើ deployment នេះមាន object storage configured សូមស្នើ presigned storage link ពី /v1/avatar/link។ Endpoint នោះ store generated object ហើយត្រឡប់ JSON មាន signed URL, object key និង hashed cache key។ Standard 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 របស់ public site ស្ថិតនៅក្នុង API repository ហើយ reusable avatar renderer ត្រូវបាន publish នៅ crates.io។ Repository · crates.io