GET
Base URL: https://api.openflags.net. All routes are GET-only — see REST API Docs for why.
Health check
GET https://api.openflags.net/api/v1/healthList flags (paginated)
page defaults to 1, page_size defaults to 20 (max 100). Results are ordered by iso_code; dir=desc reverses that order before paginating, so page 1 holds the last codes and meta is the same in both directions.
GET https://api.openflags.net/api/v1/flags?page=1&page_size=20
GET https://api.openflags.net/api/v1/flags?dir=descdir must be lowercase asc (the default) or desc; anything else returns 400 {"error": "dir must be one of: asc, desc"}. It is only accepted here: search and the per-country list return their whole result set, so sort those yourself.
Filtering by artwork
62% of the catalogue has no flag artwork yet (coat-of-arms-only and stub entries). Every flag object reports a boolean has_image, and has_image=true narrows a list to the entries that have one:
GET https://api.openflags.net/api/v1/flags?has_image=true&page_size=50
GET https://api.openflags.net/api/v1/search?q=mexico&has_image=true
GET https://api.openflags.net/api/v1/countries/US/flags?has_image=true
GET https://api.openflags.net/api/v1/flags/random?has_image=trueFiltering happens before pagination, so meta describes the filtered set and every page is full — don't filter client-side for this. has_image=false asks for the opposite set. The value must be the lowercase string true or false; anything else returns 400 {"error": "has_image must be one of: true, false"}. Leaving the parameter off returns the whole catalogue.
Get a single flag by ISO 3166 code
GET https://api.openflags.net/api/v1/flags/:iso_codeReturns 404 {"error": "Flag not found"} if the code doesn't exist.
Search flags
Returns every match, unpaginated. A missing q returns 400 {"error": "Missing 'q' parameter"}.
GET https://api.openflags.net/api/v1/search?q=:term
GET https://api.openflags.net/api/v1/search?q=:term&has_image=trueList flags for a country
Ordered by iso_code. An unknown country is an empty list, not a 404.
GET https://api.openflags.net/api/v1/countries/:iso/flags
GET https://api.openflags.net/api/v1/countries/:iso/flags?has_image=trueRandom flag (JSON)
has_image=true keeps retrying out of your code — it only ever returns a flag that has artwork.
GET https://api.openflags.net/api/v1/flags/random
GET https://api.openflags.net/api/v1/flags/random?has_image=trueRandom flag image (direct SVG)
GET https://api.openflags.net/api/v1/flags/random/imageStatic flag / coat-of-arms SVG
GET https://api.openflags.net/flags/:country_iso/flag.svg
GET https://api.openflags.net/flags/:country_iso/:region_iso/flag.svgPNG conversion
size in pixels, defaults to 128, max 512.
GET https://api.openflags.net/flags-png/:country/*path?size=128For runnable curl examples of each of these, see Available Routes / cURL.