APIHub
Back to Explore

Open Trivia

The Open Trivia Database provides a free JSON API that returns trivia questions, which can be filtered by category, difficulty, type, and amount, and supports optional session tokens and various encoding formats to avoid duplicate results.

Games & Comics
none
HTTPS
CORS: Unknown
Description enriched
Visit official documentation

Latency

2119ms p95

Uptime

100.0% 30d

Playground

Verified

live

Endpoints

REST · JSON
GET

/api.php

Retrieve trivia questions.

  • amount (query) — Number of questions to return (max 50).
  • category (query) — Category ID to limit questions to a single category.
  • difficulty (query) — Difficulty level of the questions (easy, medium, hard).
  • type (query) — Type of questions (multiple or boolean).
  • encode (query) — Encoding of the returned strings (urlLegacy, url3986, base64).
  • token (query) — Session token to avoid duplicate questions.
GET

/api_token.php

Manage session tokens (request, reset, etc.).

  • command (query, required) — Action to perform on the token (request, reset, etc.).
  • token (query) — The session token value (required for reset).

2 endpoints auto-detected

curl -X GET \
  "https://opentdb.com/api.php"

opentdb.com · HTTPS only