Literary Vault API Documentation

Base URL: http://localhost:8000/api/v1

Available Categories

GET /categories

Get all available question categories


curl "http://localhost:8000/api/v1/categories"

Response


{
  "categories": [
    "astronomy",
    "literature",
    "mathematics", 
    "psychology",
    "american-history"
  ]
}

Random Questions

GET /random

Get a random question from any category


curl "http://localhost:8000/api/v1/random"

Response


{
  "question": "What is the name of the galaxy closest to the Milky Way?",
  "category": "astronomy",
  "difficulty": "medium",
  "answer": "The Andromeda Galaxy (M31)"
}

Category Questions

GET /categories/{category}/questions

Get questions from a specific category


curl "http://localhost:8000/api/v1/categories/astronomy/questions"

Response


{
  "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"
    }
  ]
}

Category Statistics

GET /categories/{category}/stats

Get statistics about questions in a category


curl "http://localhost:8000/api/v1/categories/astronomy/stats"

Response


{
  "total_questions": 50,
  "difficulty_breakdown": {
    "easy": 15,
    "medium": 25,
    "hard": 10
  },
  "average_difficulty": "medium"
}

Error Responses

404 Not Found


{
  "error": "Category not found",
  "message": "The requested category 'invalid-category' does not exist"
}

400 Bad Request


{
  "error": "Invalid request",
  "message": "Missing required parameters"
}