Open Trivia DB
App · Gaming · 9 actions
Pull free trivia questions into a workflow from the Open Trivia Database: a community-built bank of tens of thousands of questions across 24 categories, three difficulties and both multiple choice and true/false. No account or API key required.
Actions
| Action | What it does |
|---|---|
| Build a quiz | Build a whole multi-round quiz in one step and get back a numbered question sheet and a matching answer key. |
| Check an answer | Mark somebody's answer against the right one, however they wrote it. |
| Get a category's question count | Find out how many questions one category holds, split into easy, medium and hard. |
| Get a trivia question | Get one trivia question with its fields at the top level, so a step that asks a single question does not have to reach through a list of one to read it. |
| Get database totals | Get the size of the whole question bank in one request: how many questions it holds overall, how many are verified, pending review or rejected, and the same breakdown for every category. |
| Get trivia questions | Get up to 50 trivia questions from the Open Trivia Database, narrowed by category, difficulty and type. |
| List categories | List every category in the Open Trivia Database with its id and name, and optionally how many questions each one holds. |
| Reset a session token | Wipe a session token's memory so every question is available to it again. |
| Start a session token | Start a session token, which is how a recurring quiz avoids asking the same question twice. |
Build a quiz
Build a whole multi-round quiz in one step and get back a numbered question sheet and a matching answer key. Open Trivia DB takes one category per request, which is exactly the shape a quiz is not, so this makes one request per round and numbers the result end to end. Pass a session token and no question repeats between the rounds. No API key required.
Inputs
- Rounds
categoriestext - Optional. One category per round, in the order they should be asked; leave it empty for a single round of mixed questions. This is the thing the API itself cannot do: it takes one category per call, so a five-round quiz is five calls, and they are made here. Give the name or the id: 18 and "Science: Computers" are the same category, and so is "computers", because the "Entertainment: " and "Science: " prefixes half of them carry are ignored. Capitals, accents and punctuation do not matter. Open Trivia DB allows one request every 5 seconds, so a five-round quiz takes about twenty seconds to build. Up to 10 rounds in one step.One or more of:
General Knowledge,Entertainment: Books,Entertainment: Film,Entertainment: Music,Entertainment: Musicals & Theatres,Entertainment: Television,Entertainment: Video Games,Entertainment: Board Games,Science & Nature,Science: Computers, and 14 more. - Questions per round
questions_per_roundnumber - Optional. How many questions to ask in each round. Between 1 and 50, which is the service's own per-request limit; 5 by default.From 1 to 50. Default:
5. - Difficulty
difficultytext - Optional. Leave it empty to mix all three. Narrowing this is the commonest reason a request finds nothing: there are far fewer hard questions than easy ones in most categories, and Get a category's question count says how many.One of:
easy,medium,hard. - Question type
question_typetext - Optional. Leave it empty for both. Multiple choice questions come back with four options; true/false with two, always in that order.One of:
multiple(Multiple choice),boolean(True or false). - Session token
tokentext - Optional. A token from Start a session token. While it is used, Open Trivia DB never hands the same question back twice, which is what a daily quiz needs. Leave it empty and repeats are possible. A token is dropped after 6 hours of inactivity.
- Shuffle seed
seedtext - Optional. Changes the order the options are shuffled into. By default the order is derived from the question itself, so the same question always lays out the same way and a reply graded later is graded against the letters that were sent. Set this only when you want a different, still repeatable, order.
Outputs
answer_keytext- The answers, numbered to match the sheet.
countnumber- How many questions came back.
difficultytext- The difficulty asked for, or null.
question_sheettext- Every question numbered, with its options and no answers: the thing to send out.
questionslist- Every question in the quiz, in the order it is asked, across all the rounds.
questions_per_roundnumber- How many were asked for in each.
round_countnumber- How many rounds the quiz has.
roundslist- The quiz broken into its rounds.
tokentext- The session token used, or null.
typetext- The type asked for, or null.
Example output
{
"answer_key": "Round 1: Computers\n1. B. Microsoft",
"count": 1,
"difficulty": null,
"question_sheet": "Round 1: Computers\n\n1. Which company was Bill Gates a co-founder of?\nA. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"questions": [
{
"answer_count": 4,
"answer_text": "B. Microsoft",
"answer_texts": [
"Apple",
"Microsoft",
"IBM",
"Dell"
],
"answers": [
{
"is_correct": false,
"letter": "A",
"number": 1,
"text": "Apple"
},
{
"is_correct": true,
"letter": "B",
"number": 2,
"text": "Microsoft"
},
{
"is_correct": false,
"letter": "C",
"number": 3,
"text": "IBM"
},
{
"is_correct": false,
"letter": "D",
"number": 4,
"text": "Dell"
}
],
"category": "Science: Computers",
"category_group": "Science",
"category_id": 18,
"category_topic": "Computers",
"correct_answer": "Microsoft",
"correct_index": 1,
"correct_letter": "B",
"correct_number": 2,
"difficulty": "easy",
"incorrect_answers": [
"Apple",
"IBM",
"Dell"
],
"options_text": "A. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"question": "Which company was Bill Gates a co-founder of?",
"question_text": "Which company was Bill Gates a co-founder of?\n\nA. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"type": "multiple",
"type_label": "Multiple choice"
}
],
"questions_per_round": 1,
"round_count": 1,
"rounds": [
{
"category": "Science: Computers",
"category_id": 18,
"count": 1,
"first_question_number": 1,
"heading": "Computers",
"number": 1,
"questions": [
{
"answer_count": 4,
"answer_text": "B. Microsoft",
"answer_texts": [
"Apple",
"Microsoft",
"IBM",
"Dell"
],
"answers": [
{
"is_correct": false,
"letter": "A",
"number": 1,
"text": "Apple"
},
{
"is_correct": true,
"letter": "B",
"number": 2,
"text": "Microsoft"
},
{
"is_correct": false,
"letter": "C",
"number": 3,
"text": "IBM"
},
{
"is_correct": false,
"letter": "D",
"number": 4,
"text": "Dell"
}
],
"category": "Science: Computers",
"category_group": "Science",
"category_id": 18,
"category_topic": "Computers",
"correct_answer": "Microsoft",
"correct_index": 1,
"correct_letter": "B",
"correct_number": 2,
"difficulty": "easy",
"incorrect_answers": [
"Apple",
"IBM",
"Dell"
],
"options_text": "A. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"question": "Which company was Bill Gates a co-founder of?",
"question_text": "Which company was Bill Gates a co-founder of?\n\nA. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"type": "multiple",
"type_label": "Multiple choice"
}
]
}
],
"token": null,
"type": null
}Check an answer
Mark somebody's answer against the right one, however they wrote it. A quiz that goes out by email or chat comes back as "b", "B.", "microsoft" or "yes", and a plain comparison marks every one of those wrong. This resolves a letter or an option number against the options the question came with, compares text without regard to case, accents or punctuation, and accepts the words people actually answer a true/false question with. Makes no request, so it is not rate limited.
Inputs
- Correct answer
correct_answertextRequired - The right answer, from the question step's correct_answer.
- Their answer
responsetextRequired - What the person actually answered. A letter, an option number, the answer itself, or - for a true/false question - a yes or a no.
- The options
answerslist - Optional, but pass it whenever the question was multiple choice: the answers list from the question step. Without it a reply of "B" is only text, and cannot be read as the second option.
Outputs
correcttrue/false- Whether the answer was right. Branch on this.
correct_answertext- The right answer, echoed back.
correct_lettertext- The right answer's letter, when the options were passed in.
feedbacktext- A sentence to send back to the person.
matched_ontext- How it was read: the option letter, the option number, the answer text, or a yes or no.
resolved_answertext- What that was read as: the option text when a letter or a number was given.
responsetext- What was answered, as it arrived.
verdicttext- "Correct" or "Incorrect", to print.
Example output
{
"correct": true,
"correct_answer": "Microsoft",
"correct_letter": "B",
"feedback": "Correct - the answer is Microsoft.",
"matched_on": "the option letter",
"resolved_answer": "Microsoft",
"response": "B",
"verdict": "Correct"
}Get a category's question count
Find out how many questions one category holds, split into easy, medium and hard. This is what to check before asking for a large or narrow batch: a request for more questions than exist fails outright rather than returning what there is, and there are far fewer hard questions than easy ones in most categories. No API key required.
Inputs
- Category
categorytextRequired - Give the name or the id: 18 and "Science: Computers" are the same category, and so is "computers", because the "Entertainment: " and "Science: " prefixes half of them carry are ignored. Capitals, accents and punctuation do not matter. Run List categories for the full set.
Outputs
by_difficultyobject- The same three numbers keyed by difficulty, to look one up without branching.
categorytext- The category's full name.
category_idnumber- Its id.
easynumber- How many are easy.
grouptext- The part of the name before the colon.
hardnumber- How many are hard.
max_per_requestnumber- The most one step could fetch from this category: the total, capped at the service's own limit of 50.
mediumnumber- How many are medium.
summarytext- The same numbers as a sentence.
topictext- The part after it.
totalnumber- How many questions it holds in total.
Example output
{
"by_difficulty": {
"easy": 43,
"hard": 24,
"medium": 56
},
"category": "Science: Computers",
"category_id": 18,
"easy": 43,
"group": "Science",
"hard": 24,
"max_per_request": 50,
"medium": 56,
"summary": "Science: Computers holds 123 questions (43 easy, 56 medium, 24 hard).",
"topic": "Computers",
"total": 123
}Get a trivia question
Get one trivia question with its fields at the top level, so a step that asks a single question does not have to reach through a list of one to read it. The question, its lettered options and the right answer are all ready to use: send question text as it stands, and keep the correct letter to mark the reply against. No API key required.
Inputs
- Category
categorytext - Optional. Leave it empty for any category. Give the name or the id: 18 and "Science: Computers" are the same category, and so is "computers", because the "Entertainment: " and "Science: " prefixes half of them carry are ignored. Capitals, accents and punctuation do not matter. Run List categories for the full set.
- Difficulty
difficultytext - Optional. Leave it empty to mix all three. Narrowing this is the commonest reason a request finds nothing: there are far fewer hard questions than easy ones in most categories, and Get a category's question count says how many.One of:
easy,medium,hard. - Question type
question_typetext - Optional. Leave it empty for both. Multiple choice questions come back with four options; true/false with two, always in that order.One of:
multiple(Multiple choice),boolean(True or false). - Session token
tokentext - Optional. A token from Start a session token. While it is used, Open Trivia DB never hands the same question back twice, which is what a daily quiz needs. Leave it empty and repeats are possible. A token is dropped after 6 hours of inactivity.
- Shuffle seed
seedtext - Optional. Changes the order the options are shuffled into. By default the order is derived from the question itself, so the same question always lays out the same way and a reply graded later is graded against the letters that were sent. Set this only when you want a different, still repeatable, order.
Outputs
answer_countnumber- How many options there are: 4 for multiple choice, 2 for true/false.
answer_texttext- The right answer with its letter, e.g. "B. Microsoft".
answer_textslist- The same options as plain strings, in the same order.
answerslist- Every option in the order to show it, right answer included. This is the list to loop over when building a form or a message.
categorytext- The category it came from, e.g. "Entertainment: Film".
category_grouptext- The part before the colon, e.g. "Entertainment". The same as the name for a category that has no prefix.
category_idnumber- That category's id, or null if it is not a known one.
category_topictext- The part after the colon, e.g. "Film". This is the one to use as a round heading.
correct_answertext- The right answer, decoded.
correct_indexnumber- Where the right answer sits in answers, counting from 0.
correct_lettertext- The right answer's label, e.g. "B". Compare a reply to this.
correct_numbernumber- The same position counting from 1.
difficultytext- How hard it is: "easy", "medium" or "hard".
incorrect_answerslist- The wrong answers, decoded, as the API separates them.
options_texttext- The options as lettered lines, e.g. "A. Apple\nB. Microsoft".
questiontext- The question, decoded into plain text. Open Trivia DB encodes every field it returns, so this is the form a message can use.
question_texttext- The question and its lettered options as one block, ready to put straight into an email or a message.
requested_categorytext- The category that was asked for, or null if any was allowed. The question's own category is in category.
requested_difficultytext- The difficulty asked for, or null.
requested_typetext- The type asked for, or null.
tokentext- The session token used, or null.
typetext- "multiple" for multiple choice, "boolean" for true/false.
type_labeltext- The same thing in words: "Multiple choice" or "True or false".
Example output
{
"answer_count": 4,
"answer_text": "B. Microsoft",
"answer_texts": [
"Apple",
"Microsoft",
"IBM",
"Dell"
],
"answers": [
{
"is_correct": false,
"letter": "A",
"number": 1,
"text": "Apple"
},
{
"is_correct": true,
"letter": "B",
"number": 2,
"text": "Microsoft"
},
{
"is_correct": false,
"letter": "C",
"number": 3,
"text": "IBM"
},
{
"is_correct": false,
"letter": "D",
"number": 4,
"text": "Dell"
}
],
"category": "Science: Computers",
"category_group": "Science",
"category_id": 18,
"category_topic": "Computers",
"correct_answer": "Microsoft",
"correct_index": 1,
"correct_letter": "B",
"correct_number": 2,
"difficulty": "easy",
"incorrect_answers": [
"Apple",
"IBM",
"Dell"
],
"options_text": "A. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"question": "Which company was Bill Gates a co-founder of?",
"question_text": "Which company was Bill Gates a co-founder of?\n\nA. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"requested_category": "Science: Computers",
"requested_difficulty": "easy",
"requested_type": "multiple",
"token": null,
"type": "multiple",
"type_label": "Multiple choice"
}Get database totals
Get the size of the whole question bank in one request: how many questions it holds overall, how many are verified, pending review or rejected, and the same breakdown for every category. The category names are joined on here, because the service reports this one by id alone. No API key required.
Inputs
None.
Outputs
categorieslist- The same four numbers for each category.
category_countnumber- How many categories are reported.
largest_categorytext- The category with the most verified questions.
largest_category_verifiednumber- How many that is.
pendingnumber- How many are still awaiting review.
rejectednumber- How many were rejected.
totalnumber- Every question in the bank.
verifiednumber- How many have been through review. These are the ones the questions endpoint hands out.
Example output
{
"categories": [
{
"id": 9,
"name": "General Knowledge",
"pending": 2735,
"rejected": 19,
"total": 3104,
"verified": 350
}
],
"category_count": 1,
"largest_category": "General Knowledge",
"largest_category_verified": 350,
"pending": 24928,
"rejected": 518,
"total": 51092,
"verified": 25646
}Get trivia questions
Get up to 50 trivia questions from the Open Trivia Database, narrowed by category, difficulty and type. Every field comes back as plain text rather than the encoded form the API returns, and every question arrives with its right and wrong answers already merged, shuffled and lettered A to D, so a message can be built from it without any further work. A numbered question sheet and its answer key come back alongside. No API key required.
Inputs
- Number of questions
amountnumber - Optional. How many questions to fetch. Between 1 and 50, which is the service's own per-request limit; 10 by default.From 1 to 50. Default:
10. - Category
categorytext - Optional. Leave it empty for any category. Give the name or the id: 18 and "Science: Computers" are the same category, and so is "computers", because the "Entertainment: " and "Science: " prefixes half of them carry are ignored. Capitals, accents and punctuation do not matter. Run List categories for the full set.
- Difficulty
difficultytext - Optional. Leave it empty to mix all three. Narrowing this is the commonest reason a request finds nothing: there are far fewer hard questions than easy ones in most categories, and Get a category's question count says how many.One of:
easy,medium,hard. - Question type
question_typetext - Optional. Leave it empty for both. Multiple choice questions come back with four options; true/false with two, always in that order.One of:
multiple(Multiple choice),boolean(True or false). - Session token
tokentext - Optional. A token from Start a session token. While it is used, Open Trivia DB never hands the same question back twice, which is what a daily quiz needs. Leave it empty and repeats are possible. A token is dropped after 6 hours of inactivity.
- Shuffle seed
seedtext - Optional. Changes the order the options are shuffled into. By default the order is derived from the question itself, so the same question always lays out the same way and a reply graded later is graded against the letters that were sent. Set this only when you want a different, still repeatable, order.
Outputs
answer_keytext- The answers, numbered to match the sheet.
categories_seenlist- The categories these questions actually came from. More than one when no category was asked for.
categorytext- The category that was asked for, by its full name, or null if any category was allowed.
category_idnumber- That category's id, or null.
countnumber- How many questions came back.
difficultytext- The difficulty asked for, or null for any.
question_sheettext- Every question numbered, with its options and no answers: the thing to send out.
questionslist- The questions, in the order the service returned them.
requestednumber- How many were asked for.
tokentext- The session token used, or null.
typetext- The type asked for, or null for both.
type_labeltext- The same in words, or "Any".
Example output
{
"answer_key": "1. B. Microsoft",
"categories_seen": [
"Science: Computers"
],
"category": "Science: Computers",
"category_id": 18,
"count": 1,
"difficulty": "easy",
"question_sheet": "1. Which company was Bill Gates a co-founder of?\nA. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"questions": [
{
"answer_count": 4,
"answer_text": "B. Microsoft",
"answer_texts": [
"Apple",
"Microsoft",
"IBM",
"Dell"
],
"answers": [
{
"is_correct": false,
"letter": "A",
"number": 1,
"text": "Apple"
},
{
"is_correct": true,
"letter": "B",
"number": 2,
"text": "Microsoft"
},
{
"is_correct": false,
"letter": "C",
"number": 3,
"text": "IBM"
},
{
"is_correct": false,
"letter": "D",
"number": 4,
"text": "Dell"
}
],
"category": "Science: Computers",
"category_group": "Science",
"category_id": 18,
"category_topic": "Computers",
"correct_answer": "Microsoft",
"correct_index": 1,
"correct_letter": "B",
"correct_number": 2,
"difficulty": "easy",
"incorrect_answers": [
"Apple",
"IBM",
"Dell"
],
"options_text": "A. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"question": "Which company was Bill Gates a co-founder of?",
"question_text": "Which company was Bill Gates a co-founder of?\n\nA. Apple\nB. Microsoft\nC. IBM\nD. Dell",
"type": "multiple",
"type_label": "Multiple choice"
}
],
"requested": 1,
"token": null,
"type": "multiple",
"type_label": "Multiple choice"
}List categories
List every category in the Open Trivia Database with its id and name, and optionally how many questions each one holds. The counts come from the one endpoint that reports them all at once rather than from asking each category in turn, which at this service's rate limit would take two minutes. Use it to build a category picker, or to choose a category at random for a daily quiz. No API key required.
Inputs
- Include question counts
include_countstrue/false - Optional. Add each category's question total. Costs one extra request, so the step takes about 5 seconds longer. Off by default.Default:
false.
Outputs
categorieslist- Every category, by name.
countnumber- How many categories there are.
idslist- Just the ids, in the same order.
includes_countstrue/false- Whether the counts were fetched.
nameslist- Just the names, in the same order.
Example output
{
"categories": [
{
"group": "General Knowledge",
"id": 9,
"name": "General Knowledge",
"topic": "General Knowledge"
}
],
"count": 1,
"ids": [
9
],
"includes_counts": false,
"names": [
"General Knowledge"
]
}Reset a session token
Wipe a session token's memory so every question is available to it again. This is the fix for a question step that starts failing because its token has already handed out everything matching the query - a narrow daily quiz will get there - and it keeps the same token rather than needing a new one threaded through the workflow. No API key required.
Inputs
- Session token
tokentextRequired - The token to reset. A token is dropped after 6 hours of inactivity.
Outputs
createdtrue/false- Always false for this action.
idle_hoursnumber- How many hours of inactivity the service drops a token after.
messagetext- What the service said about it.
notetext- What the reset did.
previous_tokentext- The token that was sent to be reset.
resettrue/false- Always true for this action.
tokentext- The token to keep using. Normally the same one, but use whatever comes back here.
Example output
{
"created": false,
"idle_hours": 6,
"message": "Token Reset Successfully!",
"note": "The token has forgotten every question it has handed out.",
"previous_token": "e4f5a3c1b09d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d",
"reset": true,
"token": "e4f5a3c1b09d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d"
}Start a session token
Start a session token, which is how a recurring quiz avoids asking the same question twice. Pass the token to every question step and Open Trivia DB will not hand back a question it has already given that token. Tokens are dropped after six hours of inactivity, and once a token has seen every question matching a query it needs resetting. No API key required.
Inputs
None.
Outputs
createdtrue/false- Always true for this action.
idle_hoursnumber- How many hours of inactivity the service drops a token after.
messagetext- What the service said about it.
notetext- What the token does and when it stops working.
resettrue/false- Always false for this action.
tokentext- The token. Pass it to the question steps that should not repeat themselves.
Example output
{
"created": true,
"idle_hours": 6,
"message": "Token Generated Successfully!",
"note": "Pass this token to every trivia step that should not repeat itself.",
"reset": false,
"token": "e4f5a3c1b09d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d"
}