API Reference

Questions API

Retrieve questions for a specific quiz. The Questions API lets you access individual questions, their answer options, and explanations.

The Question Object

A question belongs to a quiz and contains the question text, answer options, and metadata such as difficulty and ordering.

AttributeTypeDescription
idstringUnique identifier for the question (e.g., ques_xyz789)
quiz_idstringID of the parent quiz this question belongs to
textstringThe question text displayed to the user
typestringOne of: MULTIPLE_CHOICE, TRUE_FALSE, SHORT_ANSWER, MULTI_SELECT
difficultystringOne of: beginner, intermediate, advanced
orderintegerDisplay order of the question within the quiz (1-based)
explanationstring | nullOptional explanation shown after answering
answersobject[]Array of answer objects with id, text, and isCorrect fields
created_atstringISO 8601 timestamp of creation
GET/api/v1/questions

List Questions

Returns a paginated list of questions for a specific quiz. The quiz_id query parameter is required.

Query Parameters

ParameterTypeDefaultDescription
quiz_idRequiredstring-The ID of the quiz to fetch questions for
include_answersbooleantrueWhether to include the answers array in each question
typestring-Filter by question type: multiple_choice, true_false, short_answer, multi_select
difficultystring-Filter by difficulty: beginner, intermediate, advanced
limitinteger20Number of results to return (1-100)
offsetinteger0Number of results to skip for pagination

Example Request

bash
curl -X GET "https://quizapi.io/api/v1/questions?quiz_id=quiz_abc123&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

json
{
  "success": true,
  "data": [
    {
      "id": "ques_xyz789",
      "quizId": "quiz_abc123",
      "text": "What is the typeof null in JavaScript?",
      "type": "MULTIPLE_CHOICE",
      "difficulty": "MEDIUM",
      "explanation": "typeof null returns 'object' due to a legacy bug in JavaScript.",
      "answers": [
        { "id": "ans_1", "text": "null", "isCorrect": false },
        { "id": "ans_2", "text": "object", "isCorrect": true },
        { "id": "ans_3", "text": "undefined", "isCorrect": false },
        { "id": "ans_4", "text": "string", "isCorrect": false }
      ]
    },
    {
      "id": "ques_abc456",
      "quizId": "quiz_abc123",
      "text": "Which method converts JSON to a JavaScript object?",
      "type": "MULTIPLE_CHOICE",
      "difficulty": "EASY",
      "explanation": "JSON.parse() converts a JSON string into a JavaScript object.",
      "answers": [
        { "id": "ans_5", "text": "JSON.stringify()", "isCorrect": false },
        { "id": "ans_6", "text": "JSON.parse()", "isCorrect": true },
        { "id": "ans_7", "text": "JSON.convert()", "isCorrect": false },
        { "id": "ans_8", "text": "JSON.decode()", "isCorrect": false }
      ]
    }
  ],
  "meta": {
    "total": 10,
    "quizId": "quiz_abc123"
  }
}
GET/api/v1/questions/:id

Get a Question

Retrieves a single question by its ID, including its answer options and explanation.

Path Parameters

ParameterTypeDescription
idstringThe question ID (e.g., ques_xyz789)

Example Request

bash
curl -X GET "https://quizapi.io/api/v1/questions/ques_xyz789" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

json
{
  "success": true,
  "data": {
    "id": "ques_xyz789",
    "quizId": "quiz_abc123",
    "text": "What is the typeof null in JavaScript?",
    "type": "MULTIPLE_CHOICE",
    "difficulty": "MEDIUM",
    "explanation": "typeof null returns 'object' due to a legacy bug in JavaScript.",
    "answers": [
      { "id": "ans_1", "text": "null", "isCorrect": false },
      { "id": "ans_2", "text": "object", "isCorrect": true },
      { "id": "ans_3", "text": "undefined", "isCorrect": false },
      { "id": "ans_4", "text": "string", "isCorrect": false }
    ]
  }
}

Response Format

All API responses follow a consistent format. Successful single-object responses wrap the result in a data key. List endpoints include a meta object for pagination.

Status CodeDescription
200Successful request
400Bad request (missing quiz_id or validation error)
401Unauthorized (missing or invalid API key)
404Question or quiz not found
429Rate limit exceeded