Trivia
Get random trivia questions with multiple-choice answers. Filter by category and difficulty to target specific question pools.
Overview
Use Cases
- Quiz games and trivia applications
- Educational platforms and learning apps
- Social and party game features
- Daily challenge widgets
- Knowledge-testing integrations
Features
10 categories β science, history, geography, sports, music, movies, literature, math, technology, nature
Three difficulty levels β easy, medium, hard
Four answer options per question with the correct answer always included
Optional category and difficulty filtering
Each request returns a randomly selected question from the matching pool
API Endpoints
Get Trivia Question
Returns a random trivia question with multiple-choice answers. Use the optional category and difficulty query parameters to filter the question pool.
GET
https://api.requiems.xyz/v1/entertainment/trivia
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| category | string |
Optional | Filter by category. One of: science, history, geography, sports, music, movies, literature, math, technology, nature. |
| difficulty | string |
Optional | Filter by difficulty. One of: easy, medium, hard. |
Try it out
Live DemoRequest
Filter by category. One of: science, history, geography, sports, music, movies, literature, math, technology, nature.
Filter by difficulty. One of: easy, medium, hard.
Sending request...
Response Fields
| Field | Type | Description |
|---|---|---|
| question | string |
The trivia question text |
| options | array[string] |
Four multiple-choice answer options |
| answer | string |
The correct answer β always one of the values in options |
| category | string |
The category the question belongs to |
| difficulty | string |
The difficulty level of the question (easy, medium, or hard) |
Code Examples
# Random question (no filters)
curl "https://api.requiems.xyz/v1/entertainment/trivia" \
-H "requiems-api-key: YOUR_API_KEY"
# Filtered by category and difficulty
curl "https://api.requiems.xyz/v1/entertainment/trivia?category=science&difficulty=medium" \
-H "requiems-api-key: YOUR_API_KEY"
import requests
url = "https://api.requiems.xyz/v1/entertainment/trivia"
headers = {"requiems-api-key": "YOUR_API_KEY"}
params = {"category": "science", "difficulty": "medium"}
response = requests.get(url, headers=headers, params=params)
data = response.json()["data"]
print(data["question"])
print("Options:", data["options"])
print("Answer:", data["answer"])
const response = await fetch(
'https://api.requiems.xyz/v1/entertainment/trivia?category=science&difficulty=medium',
{ headers: { 'requiems-api-key': 'YOUR_API_KEY' } }
);
const { data } = await response.json();
console.log(data.question);
console.log('Options:', data.options);
console.log('Answer:', data.answer);
require 'net/http'
require 'json'
uri = URI('https://api.requiems.xyz/v1/entertainment/trivia')
uri.query = URI.encode_www_form(category: 'science', difficulty: 'medium')
request = Net::HTTP::Get.new(uri)
request['requiems-api-key'] = 'YOUR_API_KEY'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
data = JSON.parse(response.body)['data']
puts data['question']
puts "Answer: #{data['answer']}"
Error Responses
bad_request
An invalid category or difficulty value was provided
not_found
No questions match the given category and difficulty combination
unauthorized
Missing API key
forbidden
Invalid or revoked API key
Frequently Asked Questions
Ten categories are supported: science, history, geography, sports, music, movies, literature, math, technology, and nature.
Three levels are supported: easy, medium, and hard. When neither category nor difficulty is specified, a question is selected at random from the entire question pool.
Yes. The answer field always matches one of the values in the options array.
The API returns a 404 not_found error. Try broadening your filter β for example, drop the difficulty filter or use a different category.
No. While the options array is stable for a given question in the current dataset, the question returned is randomized per request.