juno-erp-client
v1.1.1
Published
A high-level TypeScript API wrapper for the JUNO Campus ERP platform, supporting automated login and session persistence.
Maintainers
Readme
Juno ERP Client
A high-level TypeScript API wrapper for the JUNO Campus ERP system (MGM University). It simplifies programmatic access from both the student and employee/management sides — student profile, attendance, results, fees, timetable, and the employee-side student-management dashboard.
Features
- 🔐 Automated Authentication: Handles the multi-step Juno login (JSESSIONID acquisition, session priming). Login is identical for students and employees — the server resolves the role from the credentials.
- 👥 Two clients, shared core:
StudentClientandEmployeeClientboth extend a common base that owns login and session management. - 💾 Session Persistence: Save/load cookies to a file, or export/import them manually (for serverless/DB storage).
- 🌐 Proxy support: Route traffic through an HTTP/HTTPS or SOCKS proxy.
- 📘 Type Safe: Written in TypeScript with interfaces for all API responses.
Installation
npm install juno-erp-clientClients at a glance
| Export | Use it for |
| --- | --- |
| StudentClient | A logged-in student accessing their own data. |
| EmployeeClient | A logged-in employee/staff member, including the student-management dashboard. |
| JunoBaseClient | Abstract base (login + session). You normally don't use this directly. |
| JunoClient | The shared client interface (type), and a deprecated value alias of StudentClient for backward compatibility. |
Backward compatibility:
import { JunoClient }still works and constructs aStudentClient. It is deprecated — preferStudentClient.
Quick Start
Student
import { StudentClient } from 'juno-erp-client';
const client = new StudentClient({ debug: true });
if (await client.login('your_username', 'your_password')) {
const profile = await client.getStudentProfile();
console.log(`Logged in as: ${profile[0].firstName} ${profile[0].lastName}`);
const attendance = await client.getAttendanceDetails();
console.log(attendance.AttendaceDetailsJObject.percent + '% attendance');
}Employee / student management
import { EmployeeClient } from 'juno-erp-client';
const client = new EmployeeClient();
await client.login('employee_username', 'employee_password');
// University-wide search (staff + students). Each hit is a discriminated union.
const results = await client.search('Khan');
for (const hit of results) {
if (hit.resultType === 'Student') {
const info = await client.getStudentPersonalInformation(Number(hit.studentId));
console.log(info.PersonalInfo.fullName, info.PersonalInfo.mobile);
}
}Configuration
new StudentClient({
baseUrl: 'https://erp.mgmu.ac.in', // default
debug: false, // verbose logging
sessionPath: './.session/cookies.json', // persist cookies to a file
autoSave: true, // save session after login (default: true if sessionPath set)
proxy: { // optional
protocol: 'http', // 'http' | 'https' | 'socks4' | 'socks5'
host: '127.0.0.1',
port: 8080,
auth: { username: 'u', password: 'p' }, // optional
},
});Session persistence
// File-based: reuse a session across runs
const client = new StudentClient({ sessionPath: './.session/cookies.json' });
if (!(await client.isLoggedIn())) {
await client.login(username, password);
}
// Manual export/import (e.g. store in Redis or a DB)
const data = client.exportSession();
const restored = new StudentClient();
restored.importSession(data);Note:
EmployeeClient.isLoggedIn()is not yet reliable — the employee session-probe endpoint hasn't been confirmed, so it may always reportfalseand trigger a re-login.StudentClient.isLoggedIn()works as expected.
Proxy helpers
parseProxyUrl and buildProxyAgent are exported for convenience:
import { parseProxyUrl } from 'juno-erp-client';
const proxy = parseProxyUrl('socks5://user:pass@host:1080');
const client = new EmployeeClient({ proxy });API overview
StudentClient (own data)
- Profile:
getStudentProfile,getPersonalInformation,getAcademicInfo,getAdmissionDetails,getAllCastes,getCountryList - Courses & Attendance:
getCourses,getAttendanceDetails,getAttendanceGraph - Results & Exams:
getStudentResults,getExamDetails - Finance:
getFeesDetails,getFeeStructureByStudentId,getFeeStructureByStudentIdOfStudentSide,getStudentReceivable - Schedule:
getTodaySchedule,getTimetableBetweenDates - Other:
search,getStudentIdFromSession,getTransferDetails,getTransferDetailsOfStudent,getProfilePicture,getProfilePictureUrl
EmployeeClient
- Search:
search(university-wide; returnsEmployeeorStudenthits) - Student management (by
studentId):getStudentPersonalInformation,getStudentAcademicInfo,getStudentAdmissionDetails,getStudentFeesDetails,getStudentFeeStructure,getStudentReceivable,getStudentAttendanceDetails,getStudentAttendanceGraph,getStudentMarksGraph,getStudentClinicalAttendanceAnalysis,getStudentExamDetails,getStudentTransferDetails,getStudentTransferHistory,getStudentEventDetails,getStudentGrievances,getStudentLibraryDetails,getStudentPlacementDetails,getStudentHostelDetails,getStudentCourseFileDetails,getStudentLeaveHistory
All methods return strongly typed promises. Refer to the TypeScript definitions for response structures.
Development
npm run build # compile TypeScript to dist/Integration tests
The tests/ scripts hit the live ERP, so they need credentials via environment variables or a gitignored .env at the repo root:
JUNO_STUDENT_USERNAME=... JUNO_STUDENT_PASSWORD=...
JUNO_EMPLOYEE_USERNAME=... JUNO_EMPLOYEE_PASSWORD=...
JUNO_USERNAME=... JUNO_PASSWORD=... # generic fallback for any rolenpm run test:login # employee login + session
npm run test:search # employee university search
npm run test:student # employee → student-management endpoints (pass an id, e.g. ... 149963)
npm run test:proxy # proxy connectivity (set JUNO_TEST_PROXY=<url>)Troubleshooting
Connectivity
On ECONNREFUSED/ETIMEDOUT, ensure erp.mgmu.ac.in is online and not blocked by a firewall/VPN.
Empty responses
Some endpoints require server-side session "priming", which login() handles. If using persisted sessions, ensure the session hasn't expired on the server.
License
MIT © Denizuh
