Public read API
Flag lookup
Clients can fetch the flag associated with a Twitch user ID. No authentication is required.
Endpoint
GET /api/flags/{twitchUserId}Try it with curl:
curl https://twitchflags.live/api/flags/18063875twitchUserId- Twitch numeric user ID. Digits only (for example
18063875).
Success response
200 OK with JSON:
{
"twitchUserId": "18063875",
"flag": "US"
}twitchUserId- Echo of the validated path parameter.
flag- ISO 3166-1 alpha-2 country or territory code (uppercase).
Error responses
All errors return JSON of the form { "error": "…" }.
| Status | error | When |
|---|---|---|
400 | invalid_twitch_user_id | Path ID is missing or not digits-only. |
404 | flag_not_set | User has not saved a flag. |
429 | rate_limited | Request was rate limited. |
503 | service_unavailable | Flag storage is temporarily unavailable. |
Headers & CORS
Access-Control-Allow-Origin: *on GET responses- Successful reads and
404 flag_not_set:Cache-Control: public, max-age=604800, s-maxage=604800, stale-while-revalidate=604800 - Successful saves and removals invalidate the affected Twitch user ID's Vercel CDN cache tag.
- Other errors:
Cache-Control: no-store OPTIONSpreflight is cacheable for 24h (Access-Control-Max-Age: 86400)