API Documentation
Overview
This document provides details about the available API endpoints for managing quizzes and questions.
Endpoints
1. Get Question by ID
Endpoint: GET /api/question/{id}
Description: Retrives details of a specific question by its ID.
Example Request:
GET http://mi7773.pythonanywhere.com/api/question/1
Response:
{
"correct_option": "a",
"id": 1,
"option_a": "Paris",
"option_b": "London",
"option_c": "Berlin",
"option_d": "Madrid",
"text": "What is the capital of France?"
}
2. Get Quiz by ID
Endpoint: GET /api/quiz/{id}
Description: Retrives details of a specific quiz by its ID.
Example Request:
GET http://mi7773.pythonanywhere.com/api/quiz/1
Response:
{
"description": "This is a sample quiz.",
"id": 1,
"questions": [
{
"correct_option": "a",
"id": 1,
"option_a": "Paris",
"option_b": "London",
"option_c": "Berlin",
"option_d": "Madrid",
"text": "What is the capital of France?"
},
{
"correct_option": "b",
"id": 2,
"option_a": "3",
"option_b": "4",
"option_c": "5",
"option_d": "6",
"text": "What is 2 + 2?"
}
],
"title": "Sample Quiz"
}
3. Get Paginated List of Quizzes
Endpoint: GET /api/quizzes
Description: Retrives a paginated list of all quizzes.
Query Parameters:
- page (integer): The page number to retrieve.
- per_page (integer): The number of quizzes per page.
Example Request:
GET http://mi7773.pythonanywhere.com/api/quizzes?page=1&per_page=2
Response:
{
"current_page": 1,
"pages": 1,
"quizzes": [
{
"description": "This is a sample quiz.",
"id": 1,
"questions": [
{
"correct_option": "a",
"id": 1,
"option_a": "Paris",
"option_b": "London",
"option_c": "Berlin",
"option_d": "Madrid",
"text": "What is the capital of France?"
},
{
"correct_option": "b",
"id": 2,
"option_a": "3",
"option_b": "4",
"option_c": "5",
"option_d": "6",
"text": "What is 2 + 2?"
}
],
"title": "Sample Quiz"
}
],
"total": 1
}
4. Get All Quizzes
Endpoint: GET /api/quizzes
Description: Retrives a complete list of all quizzes without pagination.
Example Request:
GET http://mi7773.pythonanywhere.com/api/quizzes
Response:
{
"quizzes": [
{
"description": "This is a sample quiz.",
"id": 1,
"questions": [
{
"correct_option": "a",
"id": 1,
"option_a": "Paris",
"option_b": "London",
"option_c": "Berlin",
"option_d": "Madrid",
"text": "What is the capital of France?"
},
{
"correct_option": "b",
"id": 2,
"option_a": "3",
"option_b": "4",
"option_c": "5",
"option_d": "6",
"text": "What is 2 + 2?"
}
],
"title": "Sample Quiz"
}
],
"total": 1
}