The Trivia API
An HTTP API that returns random trivia questions as JSON. You don't need a key for non-commercial use.
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
Without a key you get multiple choice questions only, up to 50 per request. A subscription key raises the per-request limit to 1,000.
categories: 10 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
8,907 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
1,094 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
Thousands 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. Each check costs 50 credits, and a key can make up to 300 a minute.
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.
Value plans can keep 5 quizzes of up to 20 questions. Regular allows 100 quizzes and Complete 1,000, each with up to 100 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!
Subscriptions unlock commercial access and premium features.
Value subscriptions give you commercial access to the API.
Regular and Complete subscriptions also include advanced features like:
- Session management to prevent duplicate questions for users
- Semantic search (find questions by meaning)
- Visual image questions for enhanced engagement
- Professional translations in multiple languages (French, Hindi, Spanish, Dutch, Turkish, and German)
- Text input questions with intelligent answer validation
- Shared quizzes so multiple users can answer the same questions
See pricing for the full breakdown of what's included in each plan.
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.
If you're building a commercial application or want access to premium features like image questions, translations, and text input questions, you'll need a paid subscription. We offer flexible plans to suit different needs:
- Starter - Perfect for small commercial projects
- Complete - Includes all premium features like images and translations
- Enterprise - Custom solutions for high-volume 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, paid plans include session management so users don't keep 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
Plus, our free tier is genuinely useful - no credit card required, no sneaky limitations. Start building today!
Ready to build something fun?
Start building with our free, public API. No account required.