Base URL: http://localhost:8000/api/v1
/categories
Get all available question categories
curl "http://localhost:8000/api/v1/categories"
{
"categories": [
"astronomy",
"literature",
"mathematics",
"psychology",
"american-history"
]
}
/random
Get a random question from any category
curl "http://localhost:8000/api/v1/random"
{
"question": "What is the name of the galaxy closest to the Milky Way?",
"category": "astronomy",
"difficulty": "medium",
"answer": "The Andromeda Galaxy (M31)"
}
/categories/{category}/questions
Get questions from a specific category
curl "http://localhost:8000/api/v1/categories/astronomy/questions"
{
"questions": [
{
"question": "What is the name of the galaxy closest to the Milky Way?",
"difficulty": "medium",
"answer": "The Andromeda Galaxy (M31)"
},
{
"question": "What is the largest planet in our solar system?",
"difficulty": "easy",
"answer": "Jupiter"
}
]
}
/categories/{category}/stats
Get statistics about questions in a category
curl "http://localhost:8000/api/v1/categories/astronomy/stats"
{
"total_questions": 50,
"difficulty_breakdown": {
"easy": 15,
"medium": 25,
"hard": 10
},
"average_difficulty": "medium"
}
{
"error": "Category not found",
"message": "The requested category 'invalid-category' does not exist"
}
{
"error": "Invalid request",
"message": "Missing required parameters"
}