Open Trivia API

⭐ Beginner's Pick Games & Comics / No Auth Required Beginner HTTPS
Free to Use Varies (check documentation)

Overview

Open Trivia DB is a free, community-sourced trivia question database with thousands of questions across many categories and difficulty levels. No API key is required, and you can request questions in multiple formats including multiple choice and true/false. It is one of the easiest APIs to start with for building quiz games or interactive learning apps.

💡

Beginner Tip

Add the ?encode=url3986 parameter to your request to safely handle special characters in questions and answers without parsing issues. You can also request a session token to avoid receiving duplicate questions in the same session.

Available Data

Use case: Integrate trivia questions data into web and mobile applications
Open Trivia data via REST API
JSON-formatted response data
Freely accessible without authentication

Example Response

JSON Response
{
  "id": 1,
  "name": "Open Trivia",
  "data": "Trivia Questions",
  "source": "Open Trivia"
}

Field Reference

response_code 0 = success, 1 = no results, 2 = invalid parameter, 3 = token not found, 4 = token empty
results Array of trivia question objects returned for your request
category The category the question belongs to (e.g. Science: Computers)
difficulty Question difficulty level: easy, medium, or hard
question The trivia question text (URL-encoded if encode=url3986 was used)
correct_answer The single correct answer; combine with incorrect_answers array to build a shuffled answer list

Implementation Example

const url = "https://opentdb.com/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

Response code 1 (No Results) Requesting more questions than are available for the chosen category and difficulty combination
Reduce the amount parameter (try 10 or fewer), or broaden the category/difficulty filters — some niche combinations have very few questions
Garbled or escaped text in questions HTML entities like & or ' appearing in the response text
Use ?encode=url3986 to get URL-encoded responses, or decode HTML entities in your app using a library or DOMParser in the browser
Response code 4 (Token Empty) You requested a session token and have exhausted all available questions for your current filters
Reset your session token via /api_token.php?command=reset&token=YOUR_TOKEN to start fresh without duplicates

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 15/20
🔒 Security 15/15
🛠 Developer XP 15/20
✓ Reliability 7/15
Response Time 210ms

Fully tested on Apr 5, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS UNKNOWN
Category Games & Comics
Difficulty Beginner
Verified: 2026-04-04

Similar APIs

View All →