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/18063875
twitchUserId
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": "…" }.

StatuserrorWhen
400invalid_twitch_user_idPath ID is missing or not digits-only.
404flag_not_setUser has not saved a flag.
429rate_limitedRequest was rate limited.
503service_unavailableFlag 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
  • OPTIONS preflight is cacheable for 24h (Access-Control-Max-Age: 86400)