How to get a YouTube channel avatar from a handle

Two ways to show a YouTube channel's profile picture from its @handle: the YouTube Data API's channels.list, or a single image URL.

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:

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.

<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.

Try it: put https://avatarsapi.com/github/torvalds in an <img src>. No key, no signup. Read the docs or create a Project.