Usage¶
This section covers general usage of the API.
Installing¶
To get started, install the package using pip
pip install pyjiit
Instantiation¶
from pyjiit import Webportal
w = Webportal()
print(w)
# Output:
# Driver Class for JIIT Webportal
pretty self-explanatory ig
Logging in¶
from pyjiit import Webportal
from pyjiit.default import CAPTCHA
w = Webportal()
s = w.student_login("username", "password", CAPTCHA)
print(w.session.clientid)
# Output:
# JAYPEE
This calls the student_login
method with username, password and CAPTCHA
The login method needs the Captcha object as well to defend against bots. But in practice, the captcha is not really tied to any state with your IP, so you can send any prefilled captcha and woohoo!!
So there is a premade CAPTCHA object in pyjiit.default
, which can be used while logging in
Changing the password¶
from pyjiit import Webportal
from pyjiit.default import CAPTCHA
w = Webportal()
w.student_login("username", "password", CAPTCHA)
w.set_password("password", "password_strong")
As usual we login and use the required method
Getting the attendance¶
# instantiate w = Webportal() and login before this
meta = w.get_attendance_meta()
header = meta.latest_header()
sem = meta.latest_semester()
print(w.get_attendance(header, sem))
# Output:
# {'currentSem': '1',
# 'studentattendancelist': [{'LTpercantage': 83.3,
# 'Lpercentage': 92.9,
# 'Lprepercentage': 0.0,
# 'Lpretotalclass': 0.0,
# 'Lpretotalpres': 0.0,
# 'Lsubjectcomponentcode': 'L',
# 'Lsubjectcomponentid': 'JISCP19050000001',
# ...
# ...
# ... many rows
# }
You first get the metadata for the attendance which contains headers (courseid, etc) and semesters.
get_attendance_meta()
returns an instance of AttendanceMeta
object which contains a list of available headers and semester.
The methods latest_header()
and latest_semester()
are self-explanatory.
You can choose any other header and semester from the lists AttendanceMeta.headers
and AttendanceMeta.semesters
.
Note
Please note that the call to get_attendance
may take over 10 seconds to complete. This wait is from the server so nothing we can do, sadly ;(
Getting Subject detail¶
# instantiate w = Webportal() and login before this
semesters = w.get_registered_semesters()
sem = semesters[0] # get latest sem
reg = w.get_registered_subjects_and_faculties(sem)
print(*reg.subjects, sep="\n")
# Output:
# RegisteredSubject(employee_name='Teacher name', employee_code='SomeCode', minor_subject='N', remarks='REG', stytype='REG', credits=4.0, subject_code='15B11CI111', subject_component_code='T', subject_desc='SOFTWARE DEVELOPMENT FUNDAMENTALS-1', subject_id='150046', audtsubject='N')
# ...
# ... more rows
print(reg.total_credits)
# Output:
22.5
We first get semester list and call the method with semester of choice.
The method get_registered_subjects_and_faculties
returns an instance of Registrations
class.
Exception Handling¶
There several exceptions that might be raised during the use of the API. One such exception is NotLoggedIn
, which is raised when you try to call a method on Webportal
, which needs authorization (student_login). Like calling get_student_bank_info
before student_login
is first called.
There are many more uses of the API, refer to next section for full API reference.