Skip to main content

Generate Quiz

Supports both text input and file upload (TXT, DOC, DOCX). Authentication is optional - authenticated users can save quizzes to their history.
POST /api/quiz/generate
curl -X POST https://api.inspir.uk/api/quiz/generate \
  -H "Content-Type: multipart/form-data" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "sourceName=Biology Chapter 3" \
  -F "content=Photosynthesis is the process by which plants convert light energy..."

Request Parameters

sourceName
string
Name/topic of the quiz source (e.g., “Biology Chapter 3”). Defaults to “Untitled Quiz” if not provided.
content
string
Text content to generate quiz from. If not provided, quiz will be generated based on the topic name.
file
file
Optional file upload (TXT, DOC, DOCX). Maximum 10MB. File content takes precedence over text content.

Response

quizId
string
Unique identifier for the saved quiz (only present for authenticated users)
sourceName
string
Name of the quiz source
questions
array
Array of generated quiz questions

Error Responses


Submit Quiz

Submit quiz answers for AI-powered grading and detailed feedback.
POST /api/quiz/submit
curl -X POST https://api.inspir.uk/api/quiz/submit \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "quizId": "123e4567-e89b-12d3-a456-426614174000",
    "questions": [
      {
        "question": "What is photosynthesis?",
        "options": ["..."],
        "correctAnswer": "The process by which plants..."
      }
    ],
    "answers": ["The process by which plants..."]
  }'

Request Parameters

quizId
string
ID of the quiz being submitted (required for saving results to history)
questions
array
required
Array of quiz questions (must match the generated quiz structure)
answers
array
required
Array of user’s answers corresponding to each question. Length must match questions array.

Response

score
number
Number of correct answers
totalQuestions
number
Total number of questions in the quiz
percentage
number
Score as a percentage (0-100)
results
array
Detailed results for each question

Error Responses


Get Quiz History

Retrieve all quiz attempts and results for the authenticated user.
This endpoint requires authentication.
GET /api/quiz/history
curl -X GET https://api.inspir.uk/api/quiz/history \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

Returns an array of quiz result objects:
id
string
Unique identifier for the quiz result
quiz_id
string
ID of the associated quiz
score
number
Number of correct answers
total_questions
number
Total number of questions
percentage
number
Score as a percentage
submitted_at
string
ISO 8601 timestamp of submission
quizzes
object
Associated quiz information

Get Quiz by ID

Retrieve a specific quiz by its ID.
GET /api/quiz/:id
curl -X GET https://api.inspir.uk/api/quiz/123e4567-e89b-12d3-a456-426614174000 \
  -H "Authorization: Bearer YOUR_TOKEN"

Path Parameters

id
string
required
The unique identifier of the quiz

Response

id
string
Quiz ID
user_id
string
ID of the user who created the quiz
source_name
string
Name of the quiz source
questions
array
Array of quiz questions (same structure as generate endpoint)
created_at
string
ISO 8601 timestamp of quiz creation
created_by_username
string
Username of the quiz creator

Error Responses


Share Quiz

Generate a shareable link for a quiz. Others can take the quiz using this link.
This endpoint requires authentication. You can only share your own quizzes.
POST /api/quiz/:quizId/share
curl -X POST https://api.inspir.uk/api/quiz/123e4567-e89b-12d3-a456-426614174000/share \
  -H "Authorization: Bearer YOUR_TOKEN"

Path Parameters

quizId
string
required
The unique identifier of the quiz to share

Response

shareToken
string
Unique token for the shared quiz
shareUrl
string
Complete shareable URL

Get Shared Quiz

Retrieve a quiz using its share token (public endpoint).
GET /api/quiz/shared/:shareToken
curl -X GET https://api.inspir.uk/api/quiz/shared/abc123def456

Path Parameters

shareToken
string
required
The share token for the quiz

Response

quizId
string
Quiz ID
sourceName
string
Name of the quiz source
questions
array
Array of quiz questions
createdBy
string
Username of the quiz creator
createdAt
string
ISO 8601 timestamp

Submit Shared Quiz

Submit answers for a shared quiz attempt.
POST /api/quiz/shared/:shareToken/submit
curl -X POST https://api.inspir.uk/api/quiz/shared/abc123def456/submit \
  -H "Content-Type: application/json" \
  -d '{
    "questions": [...],
    "answers": [...],
    "attemptName": "John Doe",
    "isGuest": true
  }'

Path Parameters

shareToken
string
required
The share token for the quiz

Request Parameters

questions
array
required
Array of quiz questions
answers
array
required
Array of user’s answers
attemptName
string
required
Name of the person taking the quiz (max 100 characters)
isGuest
boolean
Whether this is a guest attempt (default: false)

Response

Same structure as the regular submit quiz endpoint (score, results, etc.)

Get Quiz Attempts

View all attempts and statistics for a shared quiz (quiz creator only).
This endpoint requires authentication and quiz ownership.
GET /api/quiz/:quizId/attempts
curl -X GET https://api.inspir.uk/api/quiz/123e4567-e89b-12d3-a456-426614174000/attempts \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

quizInfo
object
Basic quiz information
stats
object
Overall statistics for all attempts
attempts
array
Array of individual quiz attempts

Build docs developers (and LLMs) love