# Open Trivia Database API
> Trivia questions via the open Open Trivia Database (OpenTDB) — no key. The questions endpoint returns multiple-choice and true/false questions filtered by category, difficulty (easy, medium, hard) and type, each with the question text, the correct answer and the incorrect options; answers are decoded server-side to clean text. The categories endpoint lists all 24 trivia categories with their ids, and count returns a category's question-count breakdown by difficulty. A random endpoint pulls a single question with the same filters. Real trivia data straight from OpenTDB, fetched fresh — no key. 5 endpoints. Ideal for quiz and trivia games, pub-quiz generators, icebreakers, study apps and chatbot mini-games.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/opentdb-api/..."
```

## Pricing
- **Free** (Free) — 6,400 calls/Mo, 2 req/s
- **Basic** ($8/Mo) — 85,500 calls/Mo, 8 req/s
- **Pro** ($26/Mo) — 548,500 calls/Mo, 20 req/s
- **Mega** ($79/Mo) — 2,690,000 calls/Mo, 50 req/s

## Endpoints

### Trivia

#### `GET /v1/categories` — All trivia categories

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/opentdb-api/v1/categories"
```

**Response:**
```json
{
    "data": {
        "count": 24,
        "categories": [
            {
                "id": 9,
                "name": "General Knowledge"
            },
            {
                "id": 10,
                "name": "Entertainment: Books"
            },
            {
                "id": 11,
                "name": "Entertainment: Film"
            },
            {
                "id": 12,
                "name": "Entertainment: Music"
            },
            {
                "id": 13,
                "name": "Entertainment: Musicals & Theatres"
            },
            {
                "id": 14,
                "name": "Entertainment: Television"
            },
            {
                "id": 15,
                "name": "Entertainment: Video Games"
            },
            {
                "id": 16,
                "name": "Entertainment: Board Games"
            },
            {
                "id": 17,
                "name": "Science & Nature"
            },
            {
                "id": 18,
                "name": "Science: Computers"
            },
            {
                "id": 19,
                "name": "Science: Mathematics"
            },
            {
                "id": 20,
                "name": "Mythology"
            },
            {
                "id": 21,
                "name": "Sports"
            },
            {
                "id": 22,
                "name": "Geography"
            },
            {
             
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/count` — Question counts for a category

**Parameters:**
- `category` (query, required, string) — Category id Example: `9`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/opentdb-api/v1/count?category=9"
```

**Response:**
```json
{
    "data": {
        "easy": 215,
        "hard": 77,
        "total": 469,
        "medium": 177,
        "category_id": 9
    },
    "meta": {
        "timestamp": "2026-06-08T09:48:48.877Z",
        "request_id": "921ce4c2-89a2-4468-91ed-64f95e0ff3f4"
    },
    "status": "ok",
    "message": "Count retrieved successfully",
    "success": true
}
```

#### `GET /v1/questions` — Trivia questions

**Parameters:**
- `amount` (query, optional, string) — Number of questions (1-50, default 10) Example: `10`
- `category` (query, optional, string) — Category id (see /v1/categories) Example: `9`
- `difficulty` (query, optional, string) — easy, medium or hard Example: `easy`
- `type` (query, optional, string) — multiple or boolean Example: `multiple`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/opentdb-api/v1/questions?amount=10&category=9&difficulty=easy&type=multiple"
```

**Response:**
```json
{
    "data": {
        "count": 10,
        "questions": [
            {
                "type": "multiple",
                "category": "General Knowledge",
                "question": "In \"Katamari Damacy\", you control a character known as:",
                "difficulty": "easy",
                "correct_answer": "The Prince",
                "incorrect_answers": [
                    "Fujio",
                    "Ichigo ",
                    "Foomin"
                ]
            },
            {
                "type": "multiple",
                "category": "General Knowledge",
                "question": "In DC comics where does the Green Arrow (Oliver Queen) live?",
                "difficulty": "easy",
                "correct_answer": "Star City",
                "incorrect_answers": [
                    "Central City",
                    "Gotham City",
                    "Metropolis"
                ]
            },
            {
                "type": "multiple",
                "category": "General Knowledge",
                "question": "When one is \"envious\", they are said to be what color?",
                "difficulty": "easy",
                "correct_answer": "Green",
                "incorrect_answers": [
                    "Red",
                    "Blue",
                    "Yellow"
                ]
            },
            {
                "type": "multiple",
                "category": "General Knowledge",
                "question": "W
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/random` — A single random question

**Parameters:**
- `category` (query, optional, string) — Category id Example: `9`
- `difficulty` (query, optional, string) — easy, medium or hard
- `type` (query, optional, string) — multiple or boolean

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/opentdb-api/v1/random?category=9"
```

**Response:**
```json
{
    "data": {
        "question": {
            "type": "boolean",
            "category": "General Knowledge",
            "question": "Slovakia is a member of European Union-",
            "difficulty": "easy",
            "correct_answer": "True",
            "incorrect_answers": [
                "False"
            ]
        }
    },
    "meta": {
        "timestamp": "2026-06-08T09:48:50.292Z",
        "request_id": "a4a0dca8-a139-40ac-9030-55ffb31d21ee"
    },
    "status": "ok",
    "message": "Random question retrieved successfully",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/opentdb-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "service": "opentdb-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/count": "Question-count breakdown for a category (category=<id>).",
            "GET /v1/random": "A single random question (same filters as /questions).",
            "GET /v1/questions": "Trivia questions (amount=1-50, category=<id>, difficulty=easy|medium|hard, type=multiple|boolean).",
            "GET /v1/categories": "All 24 trivia categories with ids."
        },
        "description": "Trivia questions via the open Open Trivia Database (OpenTDB): fetch multiple-choice and true/false questions filtered by category, difficulty and type; list the 24 categories; read a category's question-count breakdown; or pull a single random question. Answers are decoded to clean text. Real trivia data, no key."
    },
    "meta": {
        "timestamp": "2026-06-08T09:48:50.402Z",
        "request_id": "94872fd4-5e38-4e3a-97f9-092640f8614c"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/opentdb-api
OpenAPI spec: https://www.oanor.com/api/opentdb-api/openapi.json
