Academic Quiz API
This API provides generates multiple-choice questions (MCQs) for educational purposes. It covers core STEM subjects including Physics, Chemistry, Biology, Mathematics, and Computer Science.
Endpoint
Section titled “Endpoint” POST
/api/v1/quiz Request Parameters
Section titled “Request Parameters”The following parameters are accepted in the request body:
| Field | Type | Required | Description |
|---|---|---|---|
subject | string | Optional | Filter by subject. Options: physics, chemistry, biology, mathematics, computer. Pass random (or omit) for mixed subjects. |
count | number | Optional | Number of questions to retrieve (Max: 10, Default: 1). |
Request Examples
Section titled “Request Examples”curl -X POST https://heavstal.com.ng/api/v1/quiz \-H "Content-Type: application/json" \-H "x-api-key: <YOUR_API_KEY>" \-d '{"subject": "mathematics", "count": 5}'const response = await fetch('https://heavstal.com.ng/api/v1/quiz', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': '<YOUR_API_KEY>' }, body: JSON.stringify({ subject: 'computer', count: 1 })});
const res = await response.json();console.log(res.data[0].question);import { tools } from '@heavstal/api';
// Fetch 5 computer science questionsconst quiz = await tools.quiz("computer", 5);console.log(quiz.data[0].question);console.log(quiz.data[0].options);import requests
url = "https://heavstal.com.ng/api/v1/quiz"headers = { "Content-Type": "application/json", "x-api-key": "<YOUR_API_KEY>"}payload = { "subject": "mathematics", "count": 5}
response = requests.post(url, headers=headers, json=payload)print(response.json()["data"])Response Examples
Section titled “Response Examples”{ "status": "success", "creator": "HEAVSTAL TECH", "total_results": 1, "subject": "physics", "data": [ { "id": 1, "subject": "physics", "question": "What is the SI unit of Force?", "options": [ "Joule", "Newton", "Watt", "Pascal" ], "answer": "Newton" } ]}{ "status": "error", "error": "Count cannot exceed 10 questions per request."}