Integrācijas Ceļvedis

Palīdzība

Izmantojiet hashavatar.app tieši no pārlūka, frontend vai backend. Katrs avatara URL ir deterministisks, tāpēc tas pats identifikators un opcijas vienmēr dod to pašu rezultātu.

Pamata URL

Izmantojiet query endpoint, kad vajadzīgs vienkāršs publisks attēla 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

Izmantojiet path formu, ja vēlaties tīrākus embed URL.

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

HTML Piemērs

<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 Piemērs

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

Atbalstītie Parametri

  • 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

Aksesuāru un izteiksmju slāņi tiek piemēroti character-style ģimenēm. Object-style ģimenes, piemēram, planet, rocket, paws, mushroom, cactus, cupcake, pizza, icecream, diamond, coffee-cup un shield, tiek normalizētas uz accessory=none un expression=default.

Parakstītas Krātuves Saites

Ja šajā deployment ir konfigurēta object storage, pieprasiet presigned storage link no /v1/avatar/link. Šis endpoint saglabā ģenerēto objektu un atgriež JSON ar signed URL, object key un hashed cache key. Standarta avatara atbildes response headers neatklāj signed-link metadata.

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

Atvērtais Kods

Publiskās vietnes source atrodas API repository, un reusable avatar renderer ir publicēts crates.io. Repozitorijs · crates.io