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

PlanRate LimitBurstWebSocket
Starter10 req/min20✅
Growth60 req/min120✅
EnterpriseCustomCustom✅

Error Codes

CodeMeaning
200Success
400Bad Request — Invalid parameters
401Unauthorized — Invalid API key
429Rate Limit Exceeded
500Server Error — Try again