# blockface api: Minecraft avatar/skin API
Base URL: https://api.blockface.streethosting.com.br
REST, free, no auth required. Anonymous rate limit: 60 req/min per IP (global)
+ 20 req/10s for image endpoints. An API key raises the limit (see below).
All responses include CORS (GET only).
## Endpoints
GET /v1/skin/{username}
JSON metadata: { username, uuid, model ("default"|"slim"), source, skinId,
version, changedAt, cape, capeId, urls }. skinId changes if and only if the
skin texture changes.
404 { "error": "player_not_found" } if the nickname does not exist.
GET /v1/skin/{username}.png
Raw 64x64 skin texture (PNG).
GET /v1/avatar/{username}.png?size=256&overlay=true&bg=fda4af
2D face avatar (head front + hat layer), nearest-neighbor upscale.
size: 8..512 (snapped to a multiple of 8). overlay: true|false (default true).
bg: 6-digit hex without '#', or "transparent" (default).
GET /v1/bust/{username}.png?size=256&overlay=true&bg=fda4af
2D bust (head + torso + arms, front faces). Width = size, height = size*14/16.
Handles slim (Alex) arms and legacy 64x32 skins.
GET /v1/pfp/{username}.png?size=512&overlay=true&bg=sunset
Square profile picture, chibi style (2x head over shoulders), size up to 1024.
bg also accepts a preset (mono|teal|candy|sunset|ocean|grape|lime) or a
vertical gradient "top-bottom" (e.g. fda4af-fbbf24).
GET /v1/cape/{username}.png
Official account cape (64x32 PNG). 404 { "error": "no_cape" } if none.
GET /v1/live/{username} (WebSocket, API key required)
Realtime skin changes. On connect you get a "snapshot" message, then an
"update" message whenever the skin, model or cape changes:
{ type, username, uuid, model, skinId, cape, source, changedAt, urls }
urls carry ?v={version}, so swapping the
src shows the new skin at once.
Send "ping" at least every 60s (you get "pong"); silent sockets are closed
after 2 minutes (close code 4008). Browsers: pass the key as ?key=.
Each key watches a limited number of distinct players at once (default 25)
and up to 20 sockets per player; beyond that: 429 { "error": "live_limit" }.
GET /v1/key (API key required)
{ id, name, rpm, remaining, reset } for the key in use.
GET /health -> { "ok": true }
## API keys
Send the key as header "x-api-key: sh_...", "Authorization: Bearer sh_...",
or query "?key=sh_..." (only when headers are impossible, e.g.
; the key
becomes visible in the URL). A valid key replaces the per-IP limits with the
key's own requests-per-minute limit, applied globally across all endpoints.
Responses then carry x-ratelimit-limit, x-ratelimit-remaining, x-ratelimit-reset.
Keys sent in a header also unlock ?fresh=1 (skip the profile cache, fetch the
skin upstream now); keys sent as ?key= do not.
Keys are issued by the StreetHosting team; there is no self-service signup.
The same key can also be enabled for the mcstatus and motdlab APIs, with a
separate limit on each (see https://api.keys.streethosting.com.br/llms.txt).
## Caching
- Profile (nickname -> current skin) is cached 60s, served stale while it
revalidates in the background, so a new skin shows up within about a minute.
- Textures and rendered images are content-addressed by skinId and never stale.
- Image responses have an ETag; send If-None-Match to get 304 Not Modified.
- Add ?v={version} (the "version" field of /v1/skin, or the urls from the live
socket) for an immutable URL cached for a year. version = skinId plus the
model, so a classic/slim switch also changes it. Capes use ?v={capeId}.
A ?v that no longer matches is answered with the current image and no-cache.
- Response header x-cache: hit | stale | miss | bypass; x-skin-id: current skinId.
## Errors
JSON: { "error": code }. Codes: invalid_username, player_not_found, no_cape,
rate_limited (429, retry-after header), upstream_error, not_found,
invalid_api_key (401), api_key_disabled (403), api_key_required (401),
api_key_not_allowed (403, key not enabled for blockface), api_keys_unavailable (503),
upgrade_required (426, /v1/live without WebSocket), live_limit (429),
live_full (503).
## Notes for agents
- Usernames match ^[A-Za-z0-9_]{2,16}$; validate before calling.
- Image URLs are stable and embeddable (e.g. Discord, GitHub README).
- Never put an API key in public HTML or a public repo.