Core API Reference
This document provides a comprehensive reference for the core API components of pyjiit. It covers the Webportal class (the main API client), WebportalSession (session management), and the overall structure of API interactions with the JIIT Webportal backend.
For detailed information on authentication and login flow, see Authentication Flow. For security and encryption details, see Security and Encryption. For specific data model structures, see the subsections under Data Models.
Overview
The core API is implemented in pyjiit/wrapper.py The primary entry point is the Webportal class, which provides methods for all JIIT Webportal operations. After authentication via student_login(), a WebportalSession object maintains the session state and authorization tokens for subsequent API calls.
Sources: pyjiit/wrapper.py1-489 pyjiit/__init__.py1-3
Core Class Hierarchy

Sources: pyjiit/wrapper.py1-489 pyjiit/__init__.py1-3
Webportal Class
The Webportal class at pyjiit/wrapper.py70-489 is the main API client. It manages the session lifecycle and provides methods for all webportal operations.
Initialization
# No parameters required
webportal = Webportal()
The constructor pyjiit/wrapper.py76-77 initializes with self.session = None. The session is populated after successful authentication via student_login().
Sources: pyjiit/wrapper.py70-77
Internal Request Handler: __hit()
The __hit() method at pyjiit/wrapper.py82-108 is the internal HTTP request handler used by all API methods. It centralizes:
| Responsibility | Implementation |
|---|---|
| Header Management | Injects LocalName header (unauthenticated) or full auth headers (authenticated) |
| Request Execution | Delegates to requests.request() with provided arguments |
| Session Validation | Checks for HTTP 401 status, raises SessionExpired |
| Response Validation | Checks responseStatus, raises custom exceptions on failure |
| Exception Customization | Accepts exception kwarg to specify which exception type to raise |

Sources: pyjiit/wrapper.py82-108
Authentication Decorator
The @authenticated decorator at pyjiit/wrapper.py19-36 enforces session validation before method execution:
def authenticated(method):
@wraps(method)
def wrapper(self, *args, **kwargs):
if self.session is None:
raise NotLoggedIn
return method(self, *args, **kwargs)
return wrapper
All methods requiring authentication are decorated with @authenticated. If called without a valid session, they raise NotLoggedIn immediately.
Sources: pyjiit/wrapper.py19-36
WebportalSession Class
The WebportalSession class at pyjiit/wrapper.py38-68 encapsulates session state after successful login.
Session Attributes
| Attribute | Type | Source | Description |
|---|---|---|---|
raw_response |
dict | wrapper.py43 | Complete raw API response |
regdata |
dict | wrapper.py44 | Registration data dictionary |
institute |
str | wrapper.py47 | Institute name (label) |
instituteid |
str | wrapper.py48 | Institute ID (value) |
memberid |
str | wrapper.py49 | Student member ID |
userid |
str | wrapper.py51 | User ID |
token |
str | wrapper.py53 | JWT authentication token |
expiry |
datetime | wrapper.py54-55 | Token expiration timestamp (decoded from JWT) |
clientid |
str | wrapper.py57 | Client ID |
membertype |
str | wrapper.py58 | Member type |
name |
str | wrapper.py59 | Student name |
get_headers() Method
The get_headers() method at pyjiit/wrapper.py61-68 generates HTTP headers required for authenticated requests:
{
"Authorization": f"Bearer {self.token}",
"LocalName": generate_local_name()
}
The LocalName header is regenerated for every request using the encryption module's generate_local_name() function.
Sources: pyjiit/wrapper.py38-68
API Method Catalog
The following table categorizes all public API methods by functionality:
Authentication Methods
| Method | Line | Parameters | Returns | Exception |
|---|---|---|---|---|
student_login() |
111-143 | username, password, captcha |
WebportalSession |
LoginError |
get_captcha() |
145-154 | None | Captcha |
APIError |
Attendance Methods
| Method | Line | Parameters | Returns | Exception |
|---|---|---|---|---|
get_attendance_meta() |
173-188 | None | AttendanceMeta |
APIError |
get_attendance() |
191-211 | header, semester |
dict | APIError |
Registration Methods
| Method | Line | Parameters | Returns | Exception |
|---|---|---|---|---|
get_registered_semesters() |
233-249 | None | list[Semester] |
APIError |
get_registered_subjects_and_faculties() |
252-269 | semester |
Registrations |
APIError |
get_subject_choices() |
473-488 | semester |
dict | APIError |
Exam Methods
| Method | Line | Parameters | Returns | Exception |
|---|---|---|---|---|
get_semesters_for_exam_events() |
273-289 | None | list[Semester] |
APIError |
get_exam_events() |
292-308 | semester |
list[ExamEvent] |
APIError |
get_exam_schedule() |
311-328 | exam_event |
dict | APIError |
Marks and Grades Methods
| Method | Line | Parameters | Returns | Exception |
|---|---|---|---|---|
get_semesters_for_marks() |
331-346 | None | list[Semester] |
APIError |
download_marks() |
349-367 | semester |
bytes (PDF) | APIError |
get_semesters_for_grade_card() |
370-383 | None | list[Semester] |
APIError |
get_grade_card() |
403-421 | semester |
dict | APIError |
get_sgpa_cgpa() |
424-438 | stynumber (optional) |
dict | APIError |
Fee Methods
| Method | Line | Parameters | Returns | Exception |
|---|---|---|---|---|
get_fines_msc_charges() |
441-456 | None | dict | APIError |
get_fee_summary() |
459-470 | None | dict | APIError |
Account Methods
| Method | Line | Parameters | Returns | Exception |
|---|---|---|---|---|
set_password() |
214-230 | old_pswd, new_pswd |
None | AccountAPIError |
get_student_bank_info() |
157-170 | None | dict | APIError |
Sources: pyjiit/wrapper.py111-488
API Endpoint Mapping
This diagram maps public API methods to their corresponding JIIT Webportal backend endpoints:

Sources: pyjiit/wrapper.py111-488
Request Payload Patterns
API methods use two payload patterns depending on the endpoint security requirements:
Pattern 1: Encrypted Payload (serialize_payload)
Used by methods requiring encryption, invoked via serialize_payload() from the encryption module:

Methods using encrypted payloads:
student_login()wrapper.py128-137get_attendance()wrapper.py207get_registered_semesters()wrapper.py244get_registered_subjects_and_faculties()wrapper.py265get_semesters_for_exam_events()wrapper.py285get_exam_events()wrapper.py304get_exam_schedule()wrapper.py324get_semesters_for_marks()wrapper.py342get_semesters_for_grade_card()wrapper.py379get_grade_card()wrapper.py419get_sgpa_cgpa()wrapper.py436get_fines_msc_charges()wrapper.py454get_subject_choices()wrapper.py486
Pattern 2: Plain JSON Payload
Used by methods where the backend accepts unencrypted JSON:

Methods using plain JSON payloads:
get_student_bank_info()wrapper.py164-168get_attendance_meta()wrapper.py180-186set_password()wrapper.py222-229get_fee_summary()wrapper.py466-469
Sources: pyjiit/wrapper.py111-488
Data Model Return Types

| Method | Return Type | Module | Description |
|---|---|---|---|
student_login() |
WebportalSession |
wrapper.py38 | Session object with auth tokens |
get_captcha() |
Captcha |
tokens.py | Captcha challenge object |
get_attendance_meta() |
AttendanceMeta |
attendance.py | Metadata for attendance queries |
get_registered_semesters() |
list[Semester] |
attendance.py | Available semesters |
get_registered_subjects_and_faculties() |
Registrations |
registration.py36 | Subject and faculty information |
get_exam_events() |
list[ExamEvent] |
exam.py4 | Exam event information |
get_semesters_for_exam_events() |
list[Semester] |
attendance.py | Semesters with exam events |
get_semesters_for_marks() |
list[Semester] |
attendance.py | Semesters with marks data |
get_semesters_for_grade_card() |
list[Semester] |
attendance.py | Semesters with grade cards |
Other methods return raw dict objects containing API response data.
Sources: pyjiit/wrapper.py111-488 pyjiit/exam.py1-23 pyjiit/registration.py1-43
Exception Flow

Exception Types by Method
| Method | Custom Exception | Line |
|---|---|---|
student_login() |
LoginError |
[130, 139](https://github.com/codelif/pyjiit/blob/0fe02955/130, 139) |
set_password() |
AccountAPIError |
229 |
| All other authenticated methods | APIError (default) |
82-106 |
Sources: pyjiit/wrapper.py19-108
API Base URL
All API requests target the base URL defined at pyjiit/wrapper.py17:
API = "https://webportal.jiit.ac.in:6011/StudentPortalAPI"
Each method appends its specific endpoint path to this base URL. For example:
get_attendance()→https://webportal.jiit.ac.in:6011/StudentPortalAPI/StudentClassAttendance/getstudentattendancedetail
Sources: pyjiit/wrapper.py17
Usage Summary
A typical API interaction flow:
- Initialize: Create a
Webportal()instance - Get Captcha: Call
get_captcha()to retrieve a captcha challenge - Authenticate: Call
student_login(username, password, captcha)to establish session - Query Data: Call authenticated methods like
get_attendance(),get_exam_schedule(), etc. - Handle Errors: Catch
NotLoggedIn,SessionExpired,LoginError,APIErroras needed
For detailed usage examples, see Quick Start Guide.
Sources: pyjiit/wrapper.py70-489