# Open Trivia Database API

> Returns trivia questions with answers, trivia categories, question counts per category and overall database totals.

Category: Entertainment & Books. Region: global. 4 endpoints at `https://api.hoshime.com/v1/opentdb/<endpoint>`, `GET` with query parameters, answering `{data, meta}` (see https://hoshime.com/docs/responses.md). Reference: https://hoshime.com/docs/platforms/opentdb
## GET /v1/opentdb/questions

Random trivia questions with their answers, optionally by category, difficulty and type.

Scope: `social:read` · Units: 1 · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `amount` | integer | no | Number of questions, from 1 to 50. (default 5; e.g. 2) |
| `category` | integer | no | Category id from opentdb/categories, such as 9 for General Knowledge. |
| `difficulty` | string | no | Difficulty of the questions. (one of easy, medium, hard) |
| `type` | string | no | Multiple choice or true/false questions. (one of multiple, boolean) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `category` (string), `correctAnswer` (string), `difficulty` (string), `incorrectAnswers` (string[]), `question` (string), `type` (string)

```bash
curl "https://api.hoshime.com/v1/opentdb/questions?amount=2" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/opentdb/categories

The trivia categories and their ids.

Scope: `social:read` · Units: 1 · Cached: 1440 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `id` (string), `name` (string)

```bash
curl "https://api.hoshime.com/v1/opentdb/categories" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/opentdb/count

How many questions one category holds, in total and by difficulty.

Scope: `social:read` · Units: 1 · Cached: 60 min

| Parameter | Type | Required | Description |
|---|---|---|---|
| `category` | integer | yes | Category id from opentdb/categories, such as 9 for General Knowledge. (e.g. 9) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `categoryId` (string), `easy` (integer (int64)), `hard` (integer (int64)), `medium` (integer (int64)), `total` (integer (int64))

```bash
curl "https://api.hoshime.com/v1/opentdb/count?category=9" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/opentdb/totals

The size of the trivia database overall and per category, with the review state of its questions.

Scope: `social:read` · Units: 1 · Cached: 360 min

| Parameter | Type | Required | Description |
|---|---|---|---|
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `categories` (CategoryTally[]), `categories[].categoryId` (string), `categories[].pending` (integer (int64)), `categories[].rejected` (integer (int64)), `categories[].total` (integer (int64)), `categories[].verified` (integer (int64)), `pending` (integer (int64)), `rejected` (integer (int64)), `total` (integer (int64)), `verified` (integer (int64))

```bash
curl "https://api.hoshime.com/v1/opentdb/totals" -H "Authorization: Bearer $HOSHIME_TOKEN"
```
