bhagyasreeborse
v1.0.1
Published
API wrapper for SRM Academia portal
Readme
SRM Academia API
A RESTful API wrapper for SRM Academia student portal using Puppeteer for browser automation. Connect any frontend to access your academic data.
Features
- 🔐 Authentication - Secure login to SRM Academia via browser automation
- 👤 Profile - Get student profile information
- 📚 Courses - View enrolled courses
- 📊 Attendance - Track attendance with summaries
- 📝 Marks - View internal marks and assessments
- 📅 Timetable - Daily and weekly class schedule
Quick Start
1. Install Dependencies
npm install2. Configure Environment
Create a .env file:
PORT=3000
[email protected]
SRM_PASSWORD=your_correct_password3. Start the Server
# Development mode (with auto-reload)
npm run dev
# Production mode
npm startThe server will start at http://localhost:3000
API Endpoints
Health Check
curl http://localhost:3000/api/healthAuthentication
Login (use your SRM credentials)
curl -X POST http://localhost:3000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"your_password"}'Or use credentials from .env:
curl -X POST http://localhost:3000/api/auth/login \
-H "Content-Type: application/json" \
-d '{}'Check Login Status
curl http://localhost:3000/api/auth/statusIf CAPTCHA appears
# 1) Call login first; if captchaRequired=true, read captcha from /tmp/after-login.png
# 2) Submit captcha:
curl -X POST http://localhost:3000/api/auth/captcha \
-H "Content-Type: application/json" \
-d '{"captcha":"YOUR_CAPTCHA_TEXT"}'Logout
curl -X POST http://localhost:3000/api/auth/logoutAcademic Data (requires login first)
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | /api/academic/profile | Get student profile |
| GET | /api/academic/courses | Get enrolled courses |
| GET | /api/academic/day-order | Get current day order |
| GET | /api/attendance | Get all attendance data |
| GET | /api/attendance/summary | Get attendance summary |
| GET | /api/marks | Get all marks |
| GET | /api/marks/internal | Get internal marks summary |
| GET | /api/timetable/today | Get today's schedule |
| GET | /api/timetable/week | Get weekly timetable |
| GET | /api/timetable/:day | Get specific day (monday-saturday) |
Usage Examples
Complete Flow
# 1. Login first
curl -X POST http://localhost:3000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"your_password"}'
# 2. Get your attendance
curl http://localhost:3000/api/attendance
# 3. Get today's timetable
curl http://localhost:3000/api/timetable/today
# 4. Logout when done
curl -X POST http://localhost:3000/api/auth/logoutJavaScript (Fetch)
const API_URL = 'http://localhost:3000/api';
// Login
async function login(email, password) {
const response = await fetch(`${API_URL}/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password })
});
return response.json();
}
// Get Attendance
async function getAttendance() {
const response = await fetch(`${API_URL}/attendance`);
return response.json();
}
// Usage
await login('[email protected]', 'your_password');
const attendance = await getAttendance();
console.log(attendance);React Example
import { useState, useEffect } from 'react';
function AttendanceDashboard() {
const [attendance, setAttendance] = useState(null);
const [loggedIn, setLoggedIn] = useState(false);
const login = async () => {
const res = await fetch('http://localhost:3000/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: '[email protected]',
password: 'your_password'
})
});
const data = await res.json();
if (data.success) setLoggedIn(true);
};
const fetchAttendance = async () => {
const res = await fetch('http://localhost:3000/api/attendance/summary');
const data = await res.json();
setAttendance(data.data);
};
useEffect(() => {
if (loggedIn) fetchAttendance();
}, [loggedIn]);
return (
<div>
{!loggedIn ? (
<button onClick={login}>Login to Academia</button>
) : (
<div>
<h2>Overall: {attendance?.overallPercentage}</h2>
{attendance?.breakdown?.map(course => (
<p key={course.course}>{course.course}: {course.percentage}</p>
))}
</div>
)}
</div>
);
}Project Structure
srm-academia-api/
├── src/
│ ├── index.js # Express server entry
│ ├── routes/
│ │ ├── auth.js # Authentication routes
│ │ ├── academic.js # Profile & courses
│ │ ├── attendance.js # Attendance routes
│ │ ├── marks.js # Marks routes
│ │ └── timetable.js # Timetable routes
│ └── services/
│ └── puppeteerService.js # Browser automation
├── .env # Your credentials (don't commit!)
├── .env.example # Example env file
├── .gitignore
├── package.json
└── README.mdHow It Works
This API uses Puppeteer (headless Chrome) to:
- Navigate to SRM Academia portal
- Handle the login form within the iframe
- Navigate to various pages and extract data
- Return structured JSON responses
Troubleshooting
"Incorrect password"
- Double-check your password on the actual SRM Academia website
- Passwords are case-sensitive
"Could not find email input"
- The portal structure may have changed
- Check
/tmp/login-debug.pngfor screenshots
Slow responses
- First request takes longer (browser launch)
- Subsequent requests are faster (session reuse)
Security Notes
⚠️ Important:
- Never commit your
.envfile with credentials - Use environment variables in production
- This is for personal use only
- The browser runs in headless mode
Requirements
- Node.js 18+
- Chromium (installed automatically with Puppeteer)
License
MIT
