Geography quizzes, "country of the day" banners, a map game's next prompt, or just realistic seed data for a form — they all need the same thing: one country, picked at random, with real fields on it.
One random country
curl "https://countries.dev/random"{
"name": "Lithuania",
"capital": "Vilnius",
"region": "Europe",
"flag": "🇱🇹"
}It's a normal country record, so every field is there — population, currencies, languages, borders, ISO codes. The response is sent with no-store, so a CDN or browser won't hand you the same country twice.
Just the fields you need
For a quiz prompt you rarely want the whole object. Trim it with fields:
curl "https://countries.dev/random?fields=name,capital,flag"const { name, capital, flag } = await fetch(
"https://countries.dev/random?fields=name,capital,flag",
).then((r) => r.json());
question.textContent = `${flag} What is the capital of ${name}?`;
answer = capital; // "Vilnius"A "country of the day"
If you want the same country for everyone on a given day rather than a true random, pick one deterministically from the full list instead — fetch all countries once and index by day-of-year:
const all = await fetch("https://countries.dev/countries?fields=name,flag")
.then((r) => r.json());
const dayOfYear = Math.floor((Date.now() / 86400000) % all.length);
const today = all[dayOfYear];Written by
Dov Azencot
At
Thu Jun 25 2026