統合ガイド

ヘルプ

hashavatar.appはブラウザ、フロントエンド、バックエンドから直接使えます。すべてのアバターURLは決定的なので、同じ識別子と同じオプションは常に同じ結果を生成します。

基本URL

単純な公開画像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

パス形式URL

よりきれいな埋め込みURLを使いたい場合は、パス形式を使います。

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

アクセサリーと表情レイヤーはキャラクター系ファミリーに適用されます。planet、rocket、paws、mushroom、cactus、cupcake、pizza、icecream、diamond、coffee-cup、shieldなどのオブジェクト系ファミリーは、accessory=none、expression=defaultに正規化されます。

署名付きストレージリンク

このデプロイでオブジェクトストレージが設定されている場合は、/v1/avatar/linkから事前署名付きストレージリンクをリクエストできます。このエンドポイントは生成済みオブジェクトを保存し、署名付きURL、オブジェクトキー、ハッシュ化されたキャッシュキーを含むJSONを返します。通常のアバターレスポンスは、署名付きリンクのメタデータをレスポンスヘッダーに出しません。

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

オープンソース

公開サイトのソースはAPIリポジトリにあり、再利用可能なアバターレンダラーはcrates.ioで公開されています。 リポジトリ · crates.io