platforms · /discord/

Discord server icon API

Get any Discord server icon from one image URL: avatarsapi.com/discord/<handle>. No Discord API key, no scraping code.

Put a Discord Handle in the URL and the response is the server icon as image bytes, ready for an <img src>. avatarapi fetches it from Discord, checks it is a real image, and caches it at the edge.

<img src="https://avatarsapi.com/discord/discord-developers" alt="">

What goes in the URL

https://avatarsapi.com/discord/<handle>

A server invite code (abc123), discord.gg/abc123, or a full invite URL.

Discord does not expose user avatars without a bot token, so this Source returns the icon of the server an invite points to.

Percent-encode the Handle if it contains a /, a space, or other reserved characters.

Options

{ "version": 1, "data": { "url": "https://…", "source": "discord", "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 server icon, the response is a 404 with a JSON body whose code is ENOTFOUND. That makes onerror a reliable fallback:

<img
  src="https://avatarsapi.com/discord/discord-developers"
  onerror="this.onerror=null; this.src='/default-avatar.svg'"
  alt="">

EUPSTREAM (502) means Discord itself failed or changed; it is usually transient. All codes are in the error table.

Related