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
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.
https://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.
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://requiems.xyz/v1/entertainment/trivia" \
-H "requiems-api-key: YOUR_API_KEY"
# Filtered by category and difficulty
curl "https://requiems.xyz/v1/entertainment/trivia?category=science&difficulty=medium" \
-H "requiems-api-key: YOUR_API_KEY"
import requests
url = "https://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://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://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
An invalid category or difficulty value was provided
No questions match the given category and difficulty combination
Missing API key
Invalid or revoked API key
Get Batch Trivia Questions
Returns up to 50 trivia questions in a single request.
https://requiems.xyz/v1/entertainment/trivia/batch
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| filters | array<object> |
Required | Array of filters to get (min: 1, max: 50). |
Try it out
Live DemoRequest
Array of filters to get (min: 1, max: 50).
Response Fields
| Field | Type | Description |
|---|---|---|
| results | array<object> |
List of trivia questions returned in the same order as the input filters. |
| results[].category | string |
The topic filter used to retrieve the trivia question. |
| results[].difficulty | string |
The complexity level filter used to retrieve the trivia question. |
| results[].error | string |
Describes why the question could not be retrieved for this filter. Omitted if the query was successful. |
| results[].data | object |
The trivia question returned for this filter. Empty if the query failed. |
| results[].data.question | string |
The trivia question text. |
| results[].data.options | array<string> |
List of possible answers for the question. |
| results[].data.answer | string |
The correct answer to the trivia question. |
| results[].data.category | string |
The category the trivia question belongs to. |
| results[].data.difficulty | string |
The difficulty level of the trivia question. |
| total | integer |
Total number of trivia results returned. |
Code Examples
curl -X POST "https://requiems.xyz/v1/entertainment/trivia/batch" \
-H "requiems-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filters": [
{ "category": "sports", "difficulty": "easy" },
{ "category": "history", "difficulty": "medium" }
]
}'
import requests
url = "https://requiems.xyz/v1/entertainment/trivia/batch"
headers = {
"requiems-api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"filters": [
{ "category": "sports", "difficulty": "easy" },
{ "category": "history", "difficulty": "medium" }
]
}
response = requests.post(url, headers=headers, json=payload)
for item in response.json()["data"]["results"]:
print(item["category"], "-", item["difficulty"])
if item.get("error"):
print("Error:", item["error"])
else:
print("Question:", item["data"]["question"])
print("Options:", item["data"]["options"])
print("Answer:", item["data"]["answer"])
const response = await fetch(
'https://requiems.xyz/v1/entertainment/trivia/batch',
{
method: 'POST',
headers: {
'requiems-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
filters: [
{ category: 'sports', difficulty: 'easy' },
{ category: 'history', difficulty: 'medium' }
]
})
}
);
const { data } = await response.json();
data.results.forEach(item => {
console.log(item.category, '-', item.difficulty);
if (item.error) {
console.log('Error:', item.error);
} else {
console.log('Question:', item.data.question);
console.log('Options:', item.data.options);
console.log('Answer:', item.data.answer);
}
});
require 'net/http'
require 'json'
uri = URI('https://requiems.xyz/v1/entertainment/trivia/batch')
request = Net::HTTP::Post.new(uri)
request['requiems-api-key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = {
filters: [
{ category: 'sports', difficulty: 'easy' },
{ category: 'history', difficulty: 'medium' }
]
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
JSON.parse(response.body)['data']['results'].each do |item|
puts "#{item['category']} - #{item['difficulty']}"
if item['error']
puts "Error: #{item['error']}"
else
puts "Question: #{item['data']['question']}"
puts "Options: #{item['data']['options']}"
puts "Answer: #{item['data']['answer']}"
end
end
Error Responses
The filters array is missing, empty, or contains more than 50 items.
Invalid JSON, malformed request body, or unexpected field types.
Missing API key.
Invalid or revoked API key.