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.
{
"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.
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.
{
"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.
Measured Score Breakdown
Live HTTP request to the API endpoint
Fully tested on Aug 10, 2026
Technical Specifications
Related Tags
Similar APIs
View All →Animal Crossing: New Horizons
⭐ Beginner's PickThe Animal Crossing: New Horizons API gives you free access to in-game data including villagers, critters, fossils, art, music, and furniture.
Autochess VNG
The Autochess VNG API provides game data for the Autochess VNG mobile game including heroes, items, and races.
Barter.VG
Barter.VG aggregates data about PC games, DLC, bundles, giveaways, and trading from Steam and other platforms.
Digimon Information
⭐ Beginner's PickThe Digimon Information API provides easy access to data about Digimon creatures, including their names, levels, types, and images.
Genshin Impact
⭐ Beginner's PickThe Genshin Impact API provides detailed game data including characters, weapons, artifacts, enemies, and domains from the popular action RPG.