Base URL: http://localhost:5000/api
POST /auth/register
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123",
"college": "MIT",
"phone": "+1234567890"
}
Response: {
"success": true,
"message": "User registered successfully",
"token": "jwt_token",
"user": { ... }
}POST /auth/login
Content-Type: application/json
{
"email": "john@example.com",
"password": "password123"
}
Response: {
"success": true,
"token": "jwt_token",
"user": { ... }
}GET /auth/me
Authorization: Bearer {token}
Response: {
"success": true,
"user": { ... }
}GET /contests
GET /contests?status=LIVE
Response: {
"success": true,
"count": 5,
"contests": [ ... ]
}GET /contests/:id
Response: {
"success": true,
"contest": { ... }
}POST /contests
Authorization: Bearer {admin_token}
Content-Type: application/json
{
"title": "Weekly Contest #1",
"description": "Test your coding skills",
"startTime": "2024-01-01T10:00:00Z",
"endTime": "2024-01-01T12:00:00Z",
"duration": 120,
"sections": {
"mcq": {
"enabled": true,
"duration": 30,
"totalMarks": 0
},
"coding": {
"enabled": true,
"duration": 90,
"totalMarks": 0
}
},
"rules": [
"No cheating allowed",
"Fair play required"
],
"isPublished": true
}POST /contests/:id/register
Authorization: Bearer {token}
Response: {
"success": true,
"message": "Successfully registered"
}GET /contests/my-contests
Authorization: Bearer {token}
Response: {
"success": true,
"contests": [ ... ]
}GET /mcq/contest/:contestId
Authorization: Bearer {token}
Response: {
"success": true,
"count": 10,
"mcqs": [ ... ]
}POST /mcq/submit
Authorization: Bearer {token}
Content-Type: application/json
{
"contestId": "contest_id",
"answers": [
{
"questionId": "question_id",
"selectedOptions": [0, 2],
"timeTaken": 45
}
]
}POST /mcq
Authorization: Bearer {admin_token}
Content-Type: application/json
{
"contestId": "contest_id",
"question": "What is 2+2?",
"options": [
{ "text": "3", "isCorrect": false },
{ "text": "4", "isCorrect": true },
{ "text": "5", "isCorrect": false }
],
"correctAnswers": [1],
"marks": 2,
"negativeMarks": 0.5,
"difficulty": "EASY",
"category": "APTITUDE"
}GET /coding/contest/:contestId
Authorization: Bearer {token}
Response: {
"success": true,
"problems": [ ... ]
}GET /coding/:id
Authorization: Bearer {token}
Response: {
"success": true,
"problem": { ... }
}POST /coding
Authorization: Bearer {admin_token}
Content-Type: application/json
{
"contestId": "contest_id",
"title": "Two Sum",
"description": "Find two numbers that add up to target",
"inputFormat": "First line: n, target...",
"outputFormat": "Two space-separated integers",
"constraints": [
"1 <= n <= 1000",
"Time limit: 2s"
],
"examples": [
{
"input": "4 9\n2 7 11 15",
"output": "0 1",
"explanation": "nums[0] + nums[1] = 2 + 7 = 9"
}
],
"testcases": [
{
"input": "4 9\n2 7 11 15",
"output": "0 1",
"hidden": false,
"points": 20
},
{
"input": "5 10\n1 2 3 4 5",
"output": "2 4",
"hidden": true,
"points": 30
}
],
"score": 100,
"difficulty": "EASY",
"timeLimit": 2,
"memoryLimit": 256,
"tags": ["array", "hash-table"]
}POST /submissions
Authorization: Bearer {token}
Content-Type: application/json
{
"contestId": "contest_id",
"problemId": "problem_id",
"sourceCode": "def solution():\n return [0, 1]",
"language": "python"
}
Response: {
"success": true,
"submission": {
"id": "submission_id",
"verdict": "ACCEPTED",
"score": 100,
"testcasesPassed": 10,
"totalTestcases": 10
}
}GET /submissions/problem/:problemId
Authorization: Bearer {token}
Response: {
"success": true,
"submissions": [ ... ]
}GET /leaderboard/:contestId
Response: {
"success": true,
"count": 100,
"leaderboard": [
{
"rank": 1,
"userId": { "name": "John Doe", ... },
"totalScore": 450,
"mcqScore": 150,
"codingScore": 300,
"timeTaken": 3600
}
]
}GET /leaderboard/:contestId/rank
Authorization: Bearer {token}
Response: {
"success": true,
"result": {
"rank": 15,
"totalScore": 320,
...
}
}GET /leaderboard/:contestId/stats
Response: {
"success": true,
"stats": {
"totalParticipants": 150,
"submitted": 120,
"averageScore": 280.5
}
}All endpoints follow this error format:
{
"success": false,
"message": "Error description"
}Common HTTP Status Codes:
200- Success201- Created400- Bad Request401- Unauthorized403- Forbidden404- Not Found500- Server Error
Include JWT token in headers:
Authorization: Bearer {your_jwt_token}
Get token from login/register response.
- 100 requests per 15 minutes per IP
- Applies to all
/api/*endpoints
{
'c': 50,
'cpp': 54,
'java': 62,
'python': 71,
'javascript': 63,
'go': 60,
'rust': 73
}curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "Test User",
"email": "test@example.com",
"password": "test123"
}'curl -X POST http://localhost:5000/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "test123"
}'curl http://localhost:5000/api/contestsFor detailed request/response examples, check the controller files in /server/controllers/