Open Trivia API

Beginner's Pick Games & Comics / No Auth Required Beginner HTTPS
Free to Use
75 B
Measured Score 0 50 100 Speed 19/30 Consistency 17/20 Security 20/20 Browser access 15/15 Transparency 4/15 TESTED 2026-08-10

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.

Measurement Record

What actually happened when we called this API from our own infrastructure. Every value below was recorded by the request, not copied from the provider's documentation.

Request
GET https://opentdb.com/api.php?amount=10&category=18&difficulty=easy&type=multiple&encode=url3986
Result
HTTP 200 · application/json · 2,815 bytes
Response time
185 ms (median of 3) · fastest 174 ms
Transport
TLSv1.3 · TLS_AES_256_GCM_SHA384 · certificate issued by Let's Encrypt
Browser CORS
Allowed — Access-Control-Allow-Origin: *
Served by
Apache
Recorded
2026-08-10

Fields Returned

Top-level fields present in the response we captured, with the type and value we actually received.

Field Type Value received
type string multiple
difficulty string easy
category string Science%3A%20Computers
question string On%20Twitter%2C%20what%20was%20the%20original…
correct_answer string 140
incorrect_answers array [1 item]

Captured Response

Captured from a real request to https://opentdb.com/api.php?amount=10&category=18&difficulty=easy&type=multiple&encode=url3986 on 2026-08-10. Long arrays and nested objects are truncated to keep the shape readable.

JSON Response · Captured
{
  "response_code": 0,
  "results": [
    {
      "type": "multiple",
      "difficulty": "easy",
      "category": "Science%3A%20Computers",
      "question": "On%20Twitter%2C%20what%20was%20the%20original%20character%20limit%20for%20a%20Tweet%3F",
      "correct_answer": "140",
      "incorrect_answers": [
        "120"
      ]
    }
  ]
}

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

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
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.

How This API Fails

We deliberately sent this API a broken request and recorded exactly what came back on 2026-08-10. Knowing the shape of an error before you hit it makes error handling much easier to write.

HTTP 429 Sending an invalid value for "amount" application/json
{
  "response_code": 5,
  "result": []
}

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

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

Measured Score Breakdown

Live HTTP request to the API endpoint

Speed 19/30
Consistency 17/20
Security 20/20
Browser access 15/15
Transparency 4/15
Endpoint Response Time 185ms

Fully tested on Aug 10, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS UNKNOWN
Category Games & Comics
Difficulty Beginner
Endpoint last called: 2026-08-10

Related Tags

Similar APIs

View All →