Trivia API Guide 2026: Open Trivia DB, The Trivia API and Other Quiz APIs

A trivia API returns quiz questions as JSON: the question, the correct answer, usually a few wrong answers, and metadata such as category and difficulty. You call an endpoint, render the question and check the player's answer. That saves you from writing and fact-checking thousands of questions yourself.

This guide compares the trivia APIs that are live in November 2026, shows how to use Open Trivia DB (the most popular free option) with session tokens and rate limits, and lists services that have shut down so you do not build on them. We checked every provider's documentation and made test requests while writing.

Trivia APIs Compared

APIQuestion formatSizeFree accessKeyCommercial use
Open Trivia DBMultiple choice, true/false5,000+ verified questions, 24 categoriesFree; 1 request per 5 s per IP; up to 50 questions per callNoCC BY-SA 4.0 licence (attribution, share-alike)
The Trivia APIMultiple choice; image and text-input questions on paid plans14,000+ questions, 10 categoriesUp to 50 questions per request, 20 requests per 5 sNo (yes for paid features)Paid subscription required
QuizAPIMultiple choice, true/false, open-endedAbout 12,000 questions, 135 categories500 calls/monthYesNot stated
API Ninjas TriviaQuestion with a free-text answer100 questions on the free plan3,000 calls/monthYesNot on the free plan
API League Random TriviaA single trivia fact (no answer options)Not stated50 tokens/day, 1 token per callYesPaid plans (from $7/mo)
API League Random RiddleRiddle with answer, 3 difficulty levelsNot stated50 tokens/day, 1 token per callYesPaid plans (from $7/mo)

Quick picks: use Open Trivia DB for a free multiple-choice quiz with no sign-up. Use The Trivia API if you need image questions, translations or a commercial licence. Use API League's trivia and riddle endpoints for "did you know?" facts and brain-teasers alongside other APIs on the same key.

Open Trivia DB (opentdb)

Open Trivia Database is a free, user-contributed question database run by PIXELTAIL GAMES. It needs no API key. The site reports over 5,000 verified questions across 24 categories, from General Knowledge and Science & Nature to Entertainment: Video Games, with thousands more submissions waiting for review.

Request parameters

All questions come from https://opentdb.com/api.php. The API helper page builds URLs for you.

A real response to https://opentdb.com/api.php?amount=1:

{
  "response_code": 0,
  "results": [
    {
      "type": "multiple",
      "difficulty": "medium",
      "category": "Entertainment: Cartoon & Animations",
      "question": "In what year did the anime adaptation of "March Comes In Like A Lion" air?",
      "correct_answer": "2016",
      "incorrect_answers": ["2017", "2018", "2015"]
    }
  ]
}

Note the HTML entities (&, "). Either decode them before display or request encode=url3986 and run each string through decodeURIComponent. For true/false questions, correct_answer is "True" or "False" and incorrect_answers holds the other value.

Rate limit and response codes

Each IP address can call the API once every 5 seconds. A second call inside that window returns HTTP 429 with response_code 5. In that error response the array key is result, not results, so check the code before reading questions. The response codes are:

Because of the 5-second limit, fetch a full round (up to 50 questions) in one call and serve it from memory instead of requesting one question at a time. If many users share your server's IP, fetch on the server and cache.

Session tokens: no repeated questions

Request a token with api_token.php?command=request and add &token=... to question requests. The API then never returns the same question twice for that token. When the pool runs out you get code 4; reset with api_token.php?command=reset&token=.... Tokens are deleted after 6 hours of inactivity.

const BASE = "https://opentdb.com";

function shuffle(items) {
  for (let i = items.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [items[i], items[j]] = [items[j], items[i]];
  }
  return items;
}

async function getToken() {
  const res = await fetch(BASE + "/api_token.php?command=request");
  return (await res.json()).token;
}

async function getRound(token, amount = 10) {
  const url = BASE + "/api.php?amount=" + amount +
    "&type=multiple&encode=url3986&token=" + token;
  const data = await (await fetch(url)).json();

  if (data.response_code === 5) throw new Error("Rate limited, retry after 5 seconds");
  if (data.response_code === 4) throw new Error("Token exhausted, reset it");
  if (data.response_code !== 0) throw new Error("Open Trivia DB code " + data.response_code);

  return data.results.map(q => ({
    question: decodeURIComponent(q.question),
    correct: decodeURIComponent(q.correct_answer),
    answers: shuffle([q.correct_answer, ...q.incorrect_answers].map(decodeURIComponent))
  }));
}

Licence

Open Trivia DB content is published under the Creative Commons Attribution-ShareAlike 4.0 International licence. That licence allows reuse, including commercially, if you credit the source and share adapted question sets under the same licence. The site does not add separate commercial terms, so read the licence and credit Open Trivia DB in your app.

The Trivia API

The Trivia API (version 2) has more than 14,000 questions across 10 categories. Without a key you can request up to 50 questions per call and up to 20 requests every 5 seconds from one IP. Each question includes correctAnswer, incorrectAnswers, question.text, difficulty, regions and tags such as topic:classic-hollywood, so you can build narrow quizzes.

curl "https://the-trivia-api.com/v2/questions?limit=1"

[
  {
    "category": "film_and_tv",
    "correctAnswer": "William Wyler",
    "incorrectAnswers": ["...", "...", "..."],
    "question": { "text": "Which director directed Ben-Hur?" },
    "tags": ["category:film-and-tv", "topic:film", "topic:classic-hollywood"],
    "type": "text_choice",
    "difficulty": "hard",
    "regions": []
  }
]

Paid features need a key in the X-API-Key header. Sessions (no repeats) come with the Regular and Complete subscriptions. Text-input questions with LLM answer checking, image questions, translations into 9 languages and semantic search require the Complete subscription. The pricing page names the plans but does not list prices.

Licence: free use is for non-commercial projects under CC BY-NC 4.0, with a discreet credit to the API. A commercial app needs a subscription.

QuizAPI

QuizAPI started as a technical quiz API and has been rebuilt as a quiz platform, currently labelled public beta. Its metadata endpoint lists 135 categories, mixing tech topics (AWS, Docker, Kubernetes, Python) with general ones (History, Geography, Movies), and about 12,000 questions. GET /api/v1/questions filters by category, difficulty (easy to expert), type (multiple choice, true/false, open-ended) and tags, and returns answers with an isCorrect flag plus an explanation.

A key is required. The free plan includes 500 API calls per month; Starter costs $1.99 per month for 10,000 calls and Pro $9.99 per month for 100,000. The rate limit is 60 requests per minute per IP. QuizAPI does not state its commercial-use terms.

API Ninjas Trivia API

API Ninjas offers /v1/trivia and /v1/triviaoftheday. Each item has a category, a question and a free-text answer, with no wrong options, so it suits typed-answer games better than multiple choice. Free users get access to only 100 questions; the full 100,000+ question pool and the category and limit parameters are premium. The free plan allows 3,000 calls per month, is meant for evaluation and demos, requires attribution and does not allow commercial use.

API League: Random Trivia and Random Riddle APIs

API League's Random Trivia API returns a single interesting fact. It does not return a question with answer options, so it fits "did you know?" widgets, loading screens and daily-fact features. An optional max-length parameter keeps facts short enough for small screens.

curl "https://api.apileague.com/retrieve-random-trivia?max-length=200&api-key=YOUR_API_KEY"

{
  "trivia": "Koalas sleep up to 20 hours a day."
}

The Random Riddle API returns a riddle with its answer and a difficulty of easy, medium or hard, which you can request with the difficulty parameter.

curl "https://api.apileague.com/retrieve-random-riddle?difficulty=easy&api-key=YOUR_API_KEY"

{
  "riddle": "What has 13 hearts but no other organs?",
  "answer": "A deck of cards",
  "difficulty": "easy"
}

Both cost 1 token per call. The free plan includes 50 tokens per day at 1 request per second, for non-commercial use with a backlink. Paid plans start with Rookie at $7 per month (500 tokens per day, commercial use, no backlink). The same key works for all 55 API League APIs, including the Random Quote, Random Joke and Search Games APIs, and there are SDKs in 21 languages. See pricing.

Trivia APIs That Have Shut Down

If an old tutorial uses either service, switch to Open Trivia DB or The Trivia API.

Building a Quiz App on a Trivia API

Designing Your Own Trivia API

If you need full control over content, a small trivia service is straightforward:

Related Guides

Frequently Asked Questions

Is there a free trivia API?

Yes. Open Trivia DB is free, needs no API key and returns up to 50 multiple-choice or true/false questions per call, with a limit of one request every 5 seconds per IP. The Trivia API is free for non-commercial use without a key.

Does Open Trivia DB need an API key?

No. Open Trivia DB does not require an API key or an account. You can call https://opentdb.com/api.php?amount=10 directly. Session tokens are optional and only prevent repeated questions.

What is the Open Trivia DB rate limit?

Each IP address can access the API once every 5 seconds, and one call returns at most 50 questions. Going faster returns HTTP 429 with response code 5.

Can I use Open Trivia DB in a commercial app?

Open Trivia DB publishes its questions under the CC BY-SA 4.0 licence, which allows commercial use if you give attribution and share adapted question sets under the same licence. The site does not add separate commercial terms.

What happened to jService?

jService, the Jeopardy-style clue API at jservice.io, has shut down and its domain returns 410 Gone. The jservice.xyz successor has also stopped hosting. Open Trivia DB and The Trivia API are live alternatives.

Which trivia API supports multiple languages?

The Trivia API offers questions in 9 languages, including Spanish, French, German and Hindi, with its Complete subscription. Open Trivia DB has no language parameter.