Home Projects Jsjiit Getting Started Quick Start Guide

Quick Start Guide

Purpose and Scope

This guide provides minimal working examples to get you started with the jsjiit library, covering authentication and basic data retrieval operations. It is designed for developers who want to quickly understand the core usage patterns and start making API calls to the JIIT Web Portal.

For detailed installation instructions, see Installation. For comprehensive API documentation of all available methods, see API Reference. For information about the internal architecture and security mechanisms, see Architecture and Design.

Overview of Basic Usage Flow

The jsjiit library follows a simple pattern: import the WebPortal class, authenticate, then call methods to retrieve data. All data retrieval methods require prior authentication and return Promises.

Basic Usage Pattern

Architecture Diagram

Importing the Library

The library can be imported as an ES module from the CDN or from local source files.

From CDN (Production)

import { WebPortal } from 'https://cdn.jsdelivr.net/npm/jsjiit@0.0.23/dist/jsjiit.min.esm.js';

From Local Source (Development)

import { WebPortal } from "./src/index.js";
Import Method Use Case File Path
CDN (versioned) Production applications jsjiit@{version}/dist/jsjiit.min.esm.js
CDN (latest) Always use latest version jsjiit/dist/jsjiit.esm.js
Local source Development and testing ./src/index.js

Authentication

All API operations require authentication. The student_login() method creates a WebPortalSession and stores it in the WebPortal instance.

Authentication Flow

Architecture Diagram

Basic Authentication Example

// Create portal instance
const portal = new WebPortal();

// Authenticate with username and password
await portal.student_login('your_username', 'your_password');

// Session is now established and stored in portal.session
// All subsequent API calls will be authenticated

The student_login() method accepts three parameters:

Parameter Type Required Default Description
username string Yes - Student username/enrollment number
password string Yes - Student password
captcha object No DEFCAPTCHA CAPTCHA bypass object

The default CAPTCHA value (DEFCAPTCHA) is defined at src/wrapper.js20 and enables login without manual CAPTCHA solving.

Common Data Retrieval Patterns

Once authenticated, the WebPortal instance provides methods to retrieve various types of data. Most methods follow a two-step pattern: first retrieve metadata (like available semesters), then fetch specific data for a selected item.

Pattern 1: Attendance Data

// Step 1: Get attendance metadata
const meta = await portal.get_attendance_meta();

// Step 2: Select semester and header
const sem = meta.latest_semester();
const header = meta.latest_header();

// Step 3: Get attendance details
const attendance = await portal.get_attendance(header, sem);

Attendance Retrieval Flow

Architecture Diagram

Pattern 2: Subject-Level Attendance

For detailed attendance of individual classes within a subject:

// After retrieving attendance as shown above
const subjectIndex = 1;
let subjectid = attendance["studentattendancelist"][subjectIndex]["subjectid"];
let individualsubjectcode = attendance["studentattendancelist"][subjectIndex]["individualsubjectcode"];

// Extract component IDs (Lecture, Practical, Tutorial)
const possibleComponentCodes = ["Lsubjectcomponentid", "Psubjectcomponentid", "Tsubjectcomponentid"];
let subjectcomponentids = [];
for (let possibleComponentCode of possibleComponentCodes) {
    if (attendance["studentattendancelist"][subjectIndex][possibleComponentCode]) {
        subjectcomponentids.push(attendance["studentattendancelist"][subjectIndex][possibleComponentCode]);
    }
}

// Get daily attendance for the subject
let subjectAttendance = await portal.get_subject_daily_attendance(
    sem, 
    subjectid, 
    individualsubjectcode, 
    subjectcomponentids
);

Pattern 3: Academic Performance (SGPA/CGPA)

// Direct retrieval - no metadata required
const sgpaCgpa = await portal.get_sgpa_cgpa();

Pattern 4: Grade Cards

// Step 1: Get available semesters
const gradeCardSems = await portal.get_semesters_for_grade_card();

// Step 2: Select semester (index 0 is latest)
const latestSem = gradeCardSems[0];

// Step 3: Retrieve grade card
const grades = await portal.get_grade_card(latestSem);

Pattern 5: Registered Subjects and Faculties

// Step 1: Get registered semesters
const registeredSems = await portal.get_registered_semesters();

// Step 2: Select semester
const latestSem = registeredSems[0];

// Step 3: Get subjects and faculty information
const registeredSubjects = await portal.get_registered_subjects_and_faculties(latestSem);

Pattern 6: Exam Events and Schedule

// Step 1: Get semesters with exam events
const examSems = await portal.get_semesters_for_exam_events();

// Step 2: Select semester
const latestSem = examSems[0];

// Step 3: Get exam events for that semester
const examEvents = await portal.get_exam_events(latestSem);

// Step 4: Get schedule for specific exam event
const examSchedule = await portal.get_exam_schedule(examEvents[0]);

Method Categories and Return Types

The following table summarizes the common methods and their return types:

Category Method Returns Requires Metadata
Authentication student_login() WebPortalSession No
Attendance get_attendance_meta() AttendanceMeta No
get_attendance() Object Yes (header + semester)
get_subject_daily_attendance() Object Yes (semester + subject info)
Academic Records get_sgpa_cgpa() Object No
get_semesters_for_grade_card() Array<Semester> No
get_grade_card() Object Yes (semester)
get_semesters_for_marks() Array<Semester> No
download_marks() void (triggers download) Yes (semester)
Registration get_registered_semesters() Array<Semester> No
get_registered_subjects_and_faculties() Registrations Yes (semester)
Exams get_semesters_for_exam_events() Array<Semester> No
get_exam_events() Array<ExamEvent> Yes (semester)
get_exam_schedule() Object Yes (exam event)
Personal get_personal_info() Object No

Complete Working Example

Here is a minimal HTML page that demonstrates the complete flow:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jsjiit Quick Start</title>
</head>
<body>
    <script type="module">
        import { WebPortal } from 'https://cdn.jsdelivr.net/npm/jsjiit@0.0.23/dist/jsjiit.min.esm.js';

        async function main() {
            // Create portal instance
            const portal = new WebPortal();

            // Authenticate
            await portal.student_login('username', 'password');

            // Get SGPA/CGPA
            const sgpaCgpa = await portal.get_sgpa_cgpa();
            console.log('Academic Performance:', sgpaCgpa);

            // Get attendance
            const meta = await portal.get_attendance_meta();
            const sem = meta.latest_semester();
            const header = meta.latest_header();
            const attendance = await portal.get_attendance(header, sem);
            console.log('Attendance:', attendance);
        }

        main().catch(console.error);
    </script>
</body>
</html>

Error Handling Basics

All authenticated methods require a valid session. If you call a method without logging in first, a NotLoggedIn exception will be thrown. For detailed error handling strategies, see Error Handling.

import { WebPortal, LoginError } from './src/index.js';

const portal = new WebPortal();

try {
    await portal.student_login(username, password);
} catch (e) {
    if (e instanceof LoginError) {
        console.error('Login failed:', e.message);
        return;
    }
}

// Now safe to call authenticated methods

Common Exception Types

Exception Class Thrown When Location
LoginError Login credentials are invalid or API error during login src/exceptions.js
NotLoggedIn Calling authenticated method without login src/exceptions.js
SessionExpired Session token has expired (HTTP 401) src/exceptions.js
APIError General API communication error src/exceptions.js

Data Model Objects

Several methods return typed objects rather than raw JSON. These objects provide convenient access to structured data:

Class Returned By Key Properties Source File
WebPortalSession student_login() token, memberid, name, enrollmentno, expiry src/wrapper.js25-70
AttendanceMeta get_attendance_meta() headers, semesters, methods: latest_semester(), latest_header() src/attendance.js
Semester Various get_semesters_*() methods registration_id, registration_code src/attendance.js
AttendanceHeader From AttendanceMeta.headers stynumber src/attendance.js
Registrations get_registered_subjects_and_faculties() Subject and faculty information src/registration.js
ExamEvent get_exam_events() exam_event_id, registration_id src/exam.js

For complete documentation of these data models, see Data Models.

Next Steps

Now that you understand the basic usage patterns:

  1. Explore all available methods: See API Reference for comprehensive documentation of all WebPortal methods
  2. Understand authentication lifecycle: See Authentication and Session Management for details on session tokens and expiry
  3. Learn about error handling: See Error Handling for recommended exception handling strategies
  4. Review security mechanisms: See Encryption and Security to understand how data is encrypted during transmission
  5. Set up local development: See Local Development Setup if you want to modify or contribute to the library