Complete API reference for TAP (Training, Academics, and Placement).
- Base URL
- Authentication
- Response Format
- Error Handling
- Authentication Endpoints
- User Endpoints
- Schedule Endpoints
- Assignment Endpoints
- Materials Endpoints
- Attendance Endpoints
- Grade Endpoints
- Analytics Endpoints
http://localhost:5000
https://api.your-domain.com
All authenticated endpoints require a JWT token in the Authorization header:
headers: {
'Authorization': 'Bearer <JWT_TOKEN>',
'Content-Type': 'application/json'
}Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
- Access Token: 7 days
- Refresh Token: 30 days
{
"success": true,
"data": {
"id": "user_id",
"name": "User Name",
"email": "user@example.com"
},
"message": "Operation successful",
"timestamp": "2025-01-01T00:00:00.000Z"
}{
"success": true,
"data": [
{ "id": "1", "name": "Item 1" },
{ "id": "2", "name": "Item 2" }
],
"pagination": {
"page": 1,
"limit": 10,
"total": 2,
"pages": 1
},
"timestamp": "2025-01-01T00:00:00.000Z"
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input data",
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
},
"timestamp": "2025-01-01T00:00:00.000Z"
}| Code | Meaning | Description |
|---|---|---|
| 200 | OK | Request successful |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | Invalid request data |
| 401 | Unauthorized | Missing or invalid authentication |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource not found |
| 409 | Conflict | Resource already exists |
| 422 | Unprocessable Entity | Validation error |
| 500 | Server Error | Internal server error |
| Code | Message | Solution |
|---|---|---|
| INVALID_TOKEN | Invalid or expired token | Refresh token or login again |
| UNAUTHORIZED | Unauthorized access | Check permissions |
| NOT_FOUND | Resource not found | Verify resource ID |
| VALIDATION_ERROR | Invalid input data | Check request body |
| DUPLICATE_EMAIL | Email already exists | Use different email |
| INVALID_CREDENTIALS | Invalid email or password | Check credentials |
Endpoint:
POST /api/auth/registerRequest Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "SecurePassword123!",
"role": "student"
}Response (201):
{
"success": true,
"data": {
"id": "user_123",
"name": "John Doe",
"email": "john@example.com",
"role": "student",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}cURL Example:
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"password": "SecurePassword123!",
"role": "student"
}'Endpoint:
POST /api/auth/loginRequest Body:
{
"email": "john@example.com",
"password": "SecurePassword123!"
}Response (200):
{
"success": true,
"data": {
"id": "user_123",
"name": "John Doe",
"email": "john@example.com",
"role": "student",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}cURL Example:
curl -X POST http://localhost:5000/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "john@example.com",
"password": "SecurePassword123!"
}'Endpoint:
POST /api/auth/refreshHeaders:
Authorization: Bearer <REFRESH_TOKEN>
Response (200):
{
"success": true,
"data": {
"token": "new_jwt_token_here"
}
}Endpoint:
POST /api/auth/logoutHeaders:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"message": "Logged out successfully"
}Endpoint:
GET /api/users/profileHeaders:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"data": {
"id": "user_123",
"name": "John Doe",
"email": "john@example.com",
"role": "student",
"avatar": "https://example.com/avatar.jpg",
"createdAt": "2025-01-01T00:00:00.000Z"
}
}Endpoint:
PUT /api/users/profileHeaders:
Authorization: Bearer <JWT_TOKEN>
Content-Type: application/json
Request Body:
{
"name": "John Smith",
"avatar": "https://example.com/new-avatar.jpg"
}Response (200):
{
"success": true,
"data": {
"id": "user_123",
"name": "John Smith",
"email": "john@example.com",
"avatar": "https://example.com/new-avatar.jpg"
}
}Endpoint:
PUT /api/users/change-passwordHeaders:
Authorization: Bearer <JWT_TOKEN>
Content-Type: application/json
Request Body:
{
"currentPassword": "OldPassword123!",
"newPassword": "NewPassword123!"
}Response (200):
{
"success": true,
"message": "Password changed successfully"
}Endpoint:
GET /api/schedulesQuery Parameters:
?page=1&limit=10&date=2025-01-01&courseId=course_123
Headers:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"data": [
{
"id": "schedule_123",
"courseId": "course_123",
"courseName": "Data Structures",
"date": "2025-01-15",
"startTime": "09:00",
"endTime": "10:30",
"room": "A101",
"instructor": "Dr. Smith"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 5
}
}Endpoint:
POST /api/schedulesHeaders:
Authorization: Bearer <JWT_TOKEN>
Content-Type: application/json
Request Body:
{
"courseId": "course_123",
"courseName": "Data Structures",
"date": "2025-01-15",
"startTime": "09:00",
"endTime": "10:30",
"room": "A101",
"instructor": "Dr. Smith"
}Response (201):
{
"success": true,
"data": {
"id": "schedule_123",
"courseId": "course_123",
"courseName": "Data Structures",
"date": "2025-01-15",
"startTime": "09:00",
"endTime": "10:30",
"room": "A101",
"instructor": "Dr. Smith"
}
}Endpoint:
PUT /api/schedules/:idHeaders:
Authorization: Bearer <JWT_TOKEN>
Content-Type: application/json
Request Body:
{
"room": "A102",
"startTime": "10:00"
}Response (200):
{
"success": true,
"data": {
"id": "schedule_123",
"room": "A102",
"startTime": "10:00"
}
}Endpoint:
DELETE /api/schedules/:idHeaders:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"message": "Schedule deleted successfully"
}Endpoint:
GET /api/assignmentsQuery Parameters:
?page=1&limit=10&courseId=course_123&status=pending
Headers:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"data": [
{
"id": "assignment_123",
"courseId": "course_123",
"title": "Assignment 1",
"description": "Complete the exercises",
"dueDate": "2025-01-20",
"status": "pending",
"totalMarks": 100,
"createdAt": "2025-01-01T00:00:00.000Z"
}
]
}Endpoint:
POST /api/assignmentsHeaders:
Authorization: Bearer <JWT_TOKEN>
Content-Type: application/json
Request Body:
{
"courseId": "course_123",
"title": "Assignment 1",
"description": "Complete the exercises",
"dueDate": "2025-01-20",
"totalMarks": 100
}Response (201):
{
"success": true,
"data": {
"id": "assignment_123",
"courseId": "course_123",
"title": "Assignment 1",
"description": "Complete the exercises",
"dueDate": "2025-01-20",
"totalMarks": 100,
"status": "active"
}
}Endpoint:
POST /api/assignments/:id/submitHeaders:
Authorization: Bearer <JWT_TOKEN>
Content-Type: multipart/form-data
Request Body:
file: <file_to_upload>
submissionText: "My submission"
Response (201):
{
"success": true,
"data": {
"id": "submission_123",
"assignmentId": "assignment_123",
"studentId": "user_123",
"file": "submission_123.pdf",
"submittedAt": "2025-01-15T10:30:00.000Z",
"status": "submitted"
}
}Endpoint:
PUT /api/assignments/:id/gradeHeaders:
Authorization: Bearer <JWT_TOKEN>
Content-Type: application/json
Request Body:
{
"studentId": "user_123",
"marks": 85,
"feedback": "Good work, needs improvement in section 2"
}Response (200):
{
"success": true,
"data": {
"id": "submission_123",
"marks": 85,
"feedback": "Good work, needs improvement in section 2",
"gradedAt": "2025-01-20T14:00:00.000Z"
}
}Endpoint:
GET /api/materialsQuery Parameters:
?page=1&limit=10&courseId=course_123&type=pdf
Headers:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"data": [
{
"id": "material_123",
"courseId": "course_123",
"title": "Chapter 1 Notes",
"description": "Introduction to Data Structures",
"file": "chapter1.pdf",
"fileSize": 2048000,
"uploadedAt": "2025-01-01T00:00:00.000Z"
}
]
}Endpoint:
POST /api/materialsHeaders:
Authorization: Bearer <JWT_TOKEN>
Content-Type: multipart/form-data
Request Body:
courseId: course_123
title: Chapter 1 Notes
description: Introduction to Data Structures
file: <file_to_upload>
Response (201):
{
"success": true,
"data": {
"id": "material_123",
"courseId": "course_123",
"title": "Chapter 1 Notes",
"file": "material_123.pdf",
"uploadedAt": "2025-01-01T00:00:00.000Z"
}
}Endpoint:
DELETE /api/materials/:idHeaders:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"message": "Material deleted successfully"
}Endpoint:
GET /api/attendanceQuery Parameters:
?page=1&limit=10&userId=user_123&date=2025-01-01&courseId=course_123
Headers:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"data": [
{
"id": "attendance_123",
"userId": "user_123",
"courseId": "course_123",
"date": "2025-01-15",
"status": "present",
"markedAt": "2025-01-15T09:00:00.000Z"
}
]
}Endpoint:
POST /api/attendanceHeaders:
Authorization: Bearer <JWT_TOKEN>
Content-Type: application/json
Request Body:
{
"userId": "user_123",
"courseId": "course_123",
"date": "2025-01-15",
"status": "present"
}Response (201):
{
"success": true,
"data": {
"id": "attendance_123",
"userId": "user_123",
"courseId": "course_123",
"date": "2025-01-15",
"status": "present"
}
}Endpoint:
GET /api/gradesQuery Parameters:
?page=1&limit=10&userId=user_123&courseId=course_123
Headers:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"data": [
{
"id": "grade_123",
"userId": "user_123",
"courseId": "course_123",
"assignmentId": "assignment_123",
"marks": 85,
"totalMarks": 100,
"percentage": 85,
"grade": "A",
"feedback": "Excellent work"
}
]
}Endpoint:
GET /api/analytics/performanceQuery Parameters:
?userId=user_123&courseId=course_123&period=semester
Headers:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"data": {
"userId": "user_123",
"averageGrade": 82.5,
"totalAssignments": 10,
"submittedAssignments": 9,
"pendingAssignments": 1,
"performanceTrend": [
{ "month": "January", "average": 80 },
{ "month": "February", "average": 85 }
]
}
}Endpoint:
GET /api/analytics/attendanceQuery Parameters:
?userId=user_123&courseId=course_123&period=semester
Headers:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"data": {
"userId": "user_123",
"totalClasses": 30,
"presentDays": 28,
"absentDays": 2,
"attendancePercentage": 93.33,
"attendanceTrend": [
{ "week": "Week 1", "percentage": 100 },
{ "week": "Week 2", "percentage": 90 }
]
}
}Endpoint:
GET /api/analytics/assignmentsQuery Parameters:
?courseId=course_123&period=semester
Headers:
Authorization: Bearer <JWT_TOKEN>
Response (200):
{
"success": true,
"data": {
"courseId": "course_123",
"totalAssignments": 10,
"submittedCount": 95,
"pendingCount": 5,
"averageMarks": 82,
"submissionRate": 95,
"assignmentStats": [
{
"assignmentId": "assignment_123",
"title": "Assignment 1",
"submissionRate": 100,
"averageMarks": 85
}
]
}
}For more information, visit the GitHub Repository