Authentication
All API requests require authentication using your API key. Pass it in the Authorization header or as a query parameter for WebSocket connections.
Header:
Authorization: Bearer eg_live_your_api_key_here
WebSocket:
wss://api.examgen.com/ws?api_key=eg_live_your_api_key_here
⚠
Never expose your API key in client-side code or public repositories. Use environment variables on your server.
WebSocket Streaming API
Real-time sequential question delivery. Best for interactive exam experiences where questions are delivered one at a time.
WS
wss://api.examgen.com/ws
Connection
Connect with your API key as a query parameter. The server will respond with a connected event.
Sending a Generation Request
{
"action": "generate",
"prompt": "FPGE Clinical Pharmacology - Drug Interactions",
"difficulty": "hard",
"count": 10,
"language": "english",
"formats": ["mcq", "multiple_correct"],
"stream_mode": "sequential"
}
Receiving Questions
Questions arrive one at a time via the question event. Each question includes the complete data, correct answer, explanation, and distractor analysis.
{
"type": "question",
"index": 1,
"total": 10,
"data": {
"question_text": "...",
"options": [...],
"correct_answer": ["B"],
"explanation": "...",
"distractor_analysis": "..."
}
}
REST API
Batch generation endpoint. Send a request and receive all questions at once.
POST
/api/v1/webhook/test
Request Body
{
"prompt": "NEET Biology: Genetics",
"difficulty": "medium",
"count": 20,
"formats": ["mcq"]
}Response
Returns 200 OK with a JSON array of question objects. Generation completes within 30 seconds for up to 50 questions.
Rate Limits
| Plan | Rate Limit | Burst | WebSocket |
|---|---|---|---|
| Starter | 10 req/min | 20 | ✅ |
| Growth | 60 req/min | 120 | ✅ |
| Enterprise | Custom | Custom | ✅ |
Error Codes
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request — Invalid parameters |
| 401 | Unauthorized — Invalid API key |
| 429 | Rate Limit Exceeded |
| 500 | Server Error — Try again |