ช่วยเหลือ
ใช้ hashavatar.app ได้โดยตรงจากเบราว์เซอร์ frontend หรือ backend ของคุณ ทุก URL อวาตาร์ให้ผลแบบกำหนดได้ ดังนั้นตัวระบุและตัวเลือกเดียวกันจะให้ผลลัพธ์เดียวกันเสมอ
URL พื้นฐาน
ใช้ endpoint แบบ query เมื่อคุณต้องการ 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 แบบ path
ใช้รูปแบบ path หากคุณต้องการ 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 hashtenant: optional namespace partition for multi-tenant appsstyle_version: optional style namespace such asv2algorithm: identity hash mode; onlysha512is supportedkind: any public hashavatar family, includingcat,dog,robot,planet,rocket,frog,panda,cupcake,pizza,octopus,knight,bear,penguin,dragon,ninja,astronaut,diamond,coffee-cup, andshieldbackground:themed,white,black,dark,light,transparent,polka-dot,striped,checkerboard,grid,sunrise,ocean, orstarryaccessory:none,glasses,hat,headphones,crown,bowtie,eyepatch,scarf,halo, orhornscolor:default,neon-mint,pastel-pink,crimson,gold, ordeep-sea-blueexpression:default,happy,grumpy,surprised,sleepy,winking,cool, orcryingshape:square,circle,squircle,hexagon, oroctagonformat: output format; onlywebpis supportedsize: from64up to1024
ชั้นอุปกรณ์เสริมและสีหน้าใช้กับตระกูลแบบตัวละคร ตระกูลแบบวัตถุ เช่น planet, rocket, paws, mushroom, cactus, cupcake, pizza, icecream, diamond, coffee-cup และ shield จะถูก normalize เป็น accessory=none และ expression=default
ลิงก์ storage ที่ลงนาม
หาก deployment นี้ตั้งค่า object storage แล้ว ให้ขอลิงก์ storage แบบ presigned จาก /v1/avatar/link endpoint นี้จะเก็บ object ที่สร้างและคืน JSON พร้อม URL ที่ลงนาม object key และ cache key ที่ hash แล้ว คำตอบอวาตาร์มาตรฐานจะไม่เปิดเผย metadata ของลิงก์ที่ลงนามใน response header
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 repository และ renderer อวาตาร์ที่นำกลับมาใช้ได้เผยแพร่บน crates.io รีโพซิทอรี · crates.io