Put a Buy Me a Coffee Handle in the URL and the response is the profile picture as image bytes, ready for an <img src>. avatarapi fetches it from Buy Me a Coffee, checks it is a real image, and caches it at the edge.
<img src="https://avatarsapi.com/buymeacoffee/buymeacoffee" alt="">
What goes in the URL
https://avatarsapi.com/buymeacoffee/<handle>
The page name from buymeacoffee.com/<name>.
Currently failing. Buy Me a Coffee lookups are failing right now while we fix this Source. Ship a fallback.
Percent-encode the Handle if it contains a /, a space, or other reserved characters.
Options
?size=16..1000sets the square size in pixels (default 400):https://avatarsapi.com/buymeacoffee/buymeacoffee?size=64?jsonreturns the resolved image URL instead of the bytes:
{ "version": 1, "data": { "url": "https://…", "source": "buymeacoffee", "kind": "username" } }
Starter Projects can also set ?ttl=1h..28d for the cache lifetime (default 7 days).
When there is no picture
If the account does not exist or has no profile picture, the response is a 404 with a JSON body whose code is ENOTFOUND. That makes onerror a reliable fallback:
<img
src="https://avatarsapi.com/buymeacoffee/buymeacoffee"
onerror="this.onerror=null; this.src='/default-avatar.svg'"
alt="">
EUPSTREAM (502) means Buy Me a Coffee itself failed or changed; it is usually transient. All codes are in the error table.