The Trivia API
An HTTP API that returns random trivia questions as JSON, picked from approved questions.
curl "https://the-trivia-api.com/v2/questions?categories=science&limit=1"[
{
"category": "science",
"id": "63adbd6704c68cc1e14b8e2b",
"correctAnswer": "Metamorphic Rocks",
"incorrectAnswers": [
"Igneous Rocks",
"Sedimentary Rocks",
"Fossils"
],
"question": {
"text": "What type of rock is formed when existing rocks are subjected to extreme heat and pressure?"
},
"tags": ["geology", "science"],
"type": "text_choice",
"difficulty": "medium",
"regions": [],
"isNiche": false
}
]Filtering questions
categories: of them, from music to food and drinkdifficulties: easy, medium or hardtags: free-form, such as geology or capital_citiesregion: a country code, which also lets in questions that only make sense in that countrylimit: 10 if you leave it out
const res = await fetch(
"https://the-trivia-api.com/v2/questions?categories=history,geography&difficulties=hard&limit=20",
{ headers: { "x-api-key": process.env.TRIVIA_API_KEY } }
);
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const questions = await res.json();
console.log(questions[0].question.text);A multiple choice question
of the questions are text_choice: one correct answer and three wrong ones, which you shuffle yourself.
What is the chemical symbol for gold?
Built with The Trivia API
Real apps and games shipping with our questions today.
It was the only API I found that offered text-input questions. Players now see new questions every round, which saves me hours of work every week.
Kwizaa, built on top of The Trivia API, provides a way to run automated trivia leagues - Quizzes drop on a schedule and results post to Discord or email.
Translations
Questions are translated into Spanish, French, German, Dutch, Turkish, Hindi, Russian and Portuguese when they are approved. An LLM writes the translations.
Available with Complete subscription- Add
language=es(or fr, de, nl, tr, hi, ru, pt) to a questions request - Text input answers can be validated in the same language
question.text
¿A qué movimiento artístico pertenece la pintura 'Gótico americano' de Grant Wood?
Image questions
questions where the four options are photos instead of text. Each option includes the image at several sizes, plus the author and source you need for attribution.
Available with Complete subscriptionPeople
Which of these is a picture of Phil Collins?
Places
Which of these pictures shows New York's Grand Central Station?
Flags, food and maps
Which of these is the flag of Thailand?
Which of these actresses is Sharon Stone?
Text input questions
of our questions have no multiple choice options. The player types an answer, you send it to POST /v2/question/:id/validate, and an LLM decides whether it is right.
Which planet has the most moons?
- Typos, alternative names and grammatical variants are accepted, so "Mupet" counts for "Muppets"
- Answers can be checked in English or any of the 8 translated languages
Sessions
Create a session for each player and pass its id when you ask for questions. The API records what that session has been sent and won't send it again.
GET /v2/session/:idreturns how many questions the session has left- Add
preview=trueto look at questions without using them up
Create a session
POST /v2/session{ "id": "abc123", "remainingQuestions": ... }Request questions
GET /v2/questions?session=abc123First request: 10 questions
Second request: 10 more, none from the first batch
const res = await fetch("https://the-trivia-api.com/v2/quiz", {
method: "POST",
headers: {
"content-type": "application/json",
"x-api-key": process.env.TRIVIA_API_KEY,
},
body: JSON.stringify({
title: "Friday Trivia",
questionIds: ["622a1c347cc59eab6f94fa49", "63adbd6704c68cc1e14b8e2b"],
}),
});
const { id } = await res.json();
const quiz = await fetch(`https://the-trivia-api.com/v2/quiz/${id}`).then((r) => r.json());Quizzes
A quiz is a title and a list of question IDs. You need a key to create one, but fetching it by id doesn't, so every player in a league or a leaderboard can load the same questions.
Semantic Search
find questions by meaning
Let players search for questions using natural language. Semantic search understands intent and returns relevant questions even when the exact keywords don't match.
- Find questions by meaning, not keywords
- Handles synonyms and different phrasing
- Topic-random questions via
GET /v2/questions?query=...
Powered by embeddings + vector search.
// Search questions by meaning
const res = await fetch(
'https://the-trivia-api.com/v2/questions/search',
{
method: 'POST',
headers: {
'content-type': 'application/json',
'x-api-key': 'your-api-key'
},
body: JSON.stringify({
mode: 'semantic',
query: 'greek mythology'
}),
}
);
// Topic-random questions about a query
const topicRes = await fetch(
'https://the-trivia-api.com/v2/questions?query=greek%20mythology&limit=10',
{
headers: {
'x-api-key': 'your-api-key'
}
}
);
Frequently Asked Questions
Everything you need to know about The Trivia API
The Trivia API is a comprehensive API that provides high-quality quiz questions across a wide range of categories. It's designed to help developers build engaging quiz applications without the hassle of managing a large question database.
The API is under active development with new questions and features being added regularly!
Getting started is simple! Just send a GET request to https://the-trivia-api.com/v2/questions and you'll receive 10 random trivia questions with their answers.
You can filter questions using URL parameters:
categories- Filter by topic (Science, History, Geography, etc.)difficulties- Choose easy, medium, or hardlimit- Control how many questions to receive
Check out our comprehensive documentation for the full API reference and examples.
The API is free for non-commercial use under a Creative Commons Attribution-NonCommercial 4.0 International License. This means you can use it freely for personal projects, education, and non-profit applications.
View our pricing page for detailed information about each plan.
We tackle duplicates in two places: when questions are added to the database, and when questions are served to your users.
During question submission, we run semantic similarity checks (not just exact text matching) to catch reworded versions of the same idea before they are accepted.
For delivery, sessions stop users seeing the same questions across requests in your app.
No large question dataset can promise zero duplicates forever as content grows, but reducing repeat questions is a core quality goal for us and something we continuously improve.
We're not just another trivia API - we offer features you won't find anywhere else:
- Image questions - The only trivia API with visual questions. Players can identify celebrities, landmarks, flags, and more
- AI-powered validation - Our text input questions use intelligent AI to accept correct answers even with different phrasing or typos
- Professional translations - Reach global audiences with questions translated in 6+ languages
- Active development - We're constantly adding new questions, categories, and features based on community feedback
- Developer-friendly - Clean API design, comprehensive docs, and responsive support