Find an API

Search public APIs with auth details & Postman guides

← All APIs

Open Trivia Database

opentdb.com · Developer Tools

Developer Tools No Auth Free & Open Trivia Games Quiz

Free trivia question API — 4,000+ verified questions across 24 categories and 3 difficulty levels. No API key required.

Authentication

No authentication requiredFree to use with no key needed.

Sample Requests

GET Get trivia questions

Get 5 medium computer science multiple-choice questions.

https://opentdb.com/api.php?type=multiple&amount=5&category=18&difficulty=medium

Hover any highlighted part to learn what it does

curl -X GET "https://opentdb.com/api.php?type=multiple&amount=5&category=18&difficulty=medium"
import requests
params = {
    "type": "multiple",
    "amount": "5",
    "category": "18",
    "difficulty": "medium"
}
response = requests.get(
    "https://opentdb.com/api.php",
    params=params,
)
print(response.json())
const url = new URL('https://opentdb.com/api.php');
url.searchParams.set('type', 'multiple');
url.searchParams.set('amount', '5');
url.searchParams.set('category', '18');
url.searchParams.set('difficulty', 'medium');

const response = await fetch(url); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
)

func main() {
	baseURL, _ := url.Parse("https://opentdb.com/api.php")
	q := baseURL.Query()
	q.Set("type", "multiple")
	q.Set("amount", "5")
	q.Set("category", "18")
	q.Set("difficulty", "medium")
	baseURL.RawQuery = q.Encode()
	targetURL := baseURL.String()
	req, _ := http.NewRequest("GET", targetURL, nil)

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://opentdb.com/api.php")
uri.query = URI.encode_www_form({
  "type" => "multiple",
  "amount" => "5",
  "category" => "18",
  "difficulty" => "medium"
})

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Get.new(uri)

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://opentdb.com/api.php?" . http_build_query([
    "type" => "multiple",
    "amount" => "5",
    "category" => "18",
    "difficulty" => "medium"
]);
$opts = ["http" => [
    "method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));

Postman Setup Guide

Get Postman ↗
  1. No API key needed
  2. GET https://opentdb.com/api.php?amount=5
  3. Categories: 9=General, 18=Science:Computers, 21=Sports, 23=History, 31=Anime
  4. Difficulty: easy, medium, hard
  5. Type: multiple (4 choices) or boolean (true/false)

What can you build with Open Trivia Database?

Open Trivia Database is a Developer Tools API. Developers commonly use developer tools APIs for:

  • automating code review and quality checks
  • integrating CI/CD pipelines and build systems
  • managing feature flags and A/B tests
  • monitoring errors and application performance
  • generating and validating test data

No authentication required. This API is open — no signup or key needed. Ideal for quick prototypes and public-facing features. Open Trivia Database is free to use, making it a low-risk choice to experiment with.

New to APIs? Read our beginner's guide

Open documentation ↗