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.
| Attribute | Type | Description |
|---|---|---|
id | string | Unique identifier for the question (e.g., ques_xyz789) |
quiz_id | string | ID of the parent quiz this question belongs to |
text | string | The question text displayed to the user |
type | string | One of: MULTIPLE_CHOICE, TRUE_FALSE, SHORT_ANSWER, MULTI_SELECT |
difficulty | string | One of: beginner, intermediate, advanced |
order | integer | Display order of the question within the quiz (1-based) |
explanation | string | null | Optional explanation shown after answering |
answers | object[] | Array of answer objects with id, text, and isCorrect fields |
created_at | string | ISO 8601 timestamp of creation |
GET
/api/v1/questionsList Questions
Returns a paginated list of questions for a specific quiz. The quiz_id query parameter is required.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
quiz_idRequired | string | - | The ID of the quiz to fetch questions for |
include_answers | boolean | true | Whether to include the answers array in each question |
type | string | - | Filter by question type: multiple_choice, true_false, short_answer, multi_select |
difficulty | string | - | Filter by difficulty: beginner, intermediate, advanced |
limit | integer | 20 | Number of results to return (1-100) |
offset | integer | 0 | Number 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/:idGet a Question
Retrieves a single question by its ID, including its answer options and explanation.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The 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 Code | Description |
|---|---|
| 200 | Successful request |
| 400 | Bad request (missing quiz_id or validation error) |
| 401 | Unauthorized (missing or invalid API key) |
| 404 | Question or quiz not found |
| 429 | Rate limit exceeded |