Every YouTube channel has an @handle and a round avatar. Here are two ways to go from one to the other.
The YouTube Data API
channels.list accepts a handle directly through the forHandle parameter and returns the avatar in snippet.thumbnails:
curl "https://www.googleapis.com/youtube/v3/channels?part=snippet&forHandle=@YouTube&key=$API_KEY"
The response carries default, medium, and high thumbnail URLs on yt3.ggpht.com. Each call costs 1 quota unit, and a project gets 10,000 units a day by default (quota docs), so cost is rarely the problem. The friction is elsewhere:
- you need a Google Cloud project and an API key, which must stay on your server
- you need to cache the result yourself and refresh it when the creator changes their picture
This is the right choice if you already use the Data API for video or channel stats.
One image URL
<img src="https://avatarsapi.com/youtube/@YouTube" alt="">
avatarapi takes the handle with its @ and returns the channel avatar as image bytes from a stable URL, cached at the edge for 7 days. No API key, no backend. Percent-encoding the @ (%40YouTube) also works.
?size=16..1000for the square size.?jsonreturns the resolvedyt3.ggpht.comURL instead of the bytes.- A handle that does not exist returns a 404 with
"code": "ENOTFOUND".
<img
src="https://avatarsapi.com/youtube/@mkbhd?size=88"
onerror="this.onerror=null; this.src='/default-avatar.svg'"
alt="">
Which to use
Use the Data API when you need other channel data and already have a backend. Use an image URL when you only need the picture in a page, an email, or a dashboard. Twitch, TikTok, and X work the same way.
https://avatarsapi.com/github/torvalds in an <img src>. No key, no signup. Read the docs or create a Project.