# Docker Hub profile picture API

> Docker Hub lookups at avatarsapi.com/dockerhub/<handle> are currently failing. Handle format and status.

Put a Docker Hub Handle in the URL and the response is the profile picture as image bytes, ready for an `<img src>`. avatarapi fetches it from Docker Hub, checks it is a real image, and caches it at the edge.

```html
<img src="https://avatarsapi.com/dockerhub/library" alt="">
```

## What goes in the URL

`https://avatarsapi.com/dockerhub/<handle>`

The Docker Hub username or organization.

**Currently failing.** Docker Hub rate-limits Cloudflare's IP ranges, so lookups fail right now. Ship a fallback.

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

## Options

- `?size=16..1000` sets the square size in pixels (default 400): `https://avatarsapi.com/dockerhub/library?size=64`
- `?json` returns the resolved image URL instead of the bytes:

```json
{ "version": 1, "data": { "url": "https://…", "source": "dockerhub", "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:

```html
<img
  src="https://avatarsapi.com/dockerhub/library"
  onerror="this.onerror=null; this.src='/default-avatar.svg'"
  alt="">
```

`EUPSTREAM` (502) means Docker Hub itself failed or changed; it is usually transient. All codes are in the [error table](https://avatarsapi.com/docs#errors).

## Related

- [Dribbble profile picture API](/platforms/dribbble)
- [Facebook profile picture API](/platforms/facebook)
- [Flickr profile picture API](/platforms/flickr)
- [Gitee profile picture API](/platforms/gitee)
- [All 67 platforms](/platforms/)
