API Reference¶
The following section gives you a clearer insight into the functions of OpenTamPy
Note
As objects are constructed directly from their Intranet response, there is no guarantee that their attributes will persist over all time. Therefore it is considered best practice to implement a try-except block for AttributeErrors
The Intranet class¶
OpenTamPy is based on this class and a few helper functions, to help you achieve your goal. All functions and attributes of the library can be called from this class For an asynchronous version of this class refer to Async
- class Intranet(username, password, school, debug=False)¶
This is the base class from where you can call all the libraries functions from. To be able to do this, you need to create an instance of this class first.
- Parameters
username (str) – Your Intranet username. This is only used for authentication purposes
password (str) – Your Intranet password. This is only used for authentication purposes
school (str) – Your schoolcode. Ex:
krmfor MNG,krrfor RGZH. Can be found in the URL. Ex: Inhttps://intranet.tam.ch/krm/, wherekrmwould be the schoolcodedebug (bool) – Whether logging should be set to debug. Defaults to False
- get_timetable(start_date=0, end_date=0, user_id=None, timeout=20)¶
- Parameters
start_date (int) – Start of the timebracket as ‘DD.MM.YY’, defaults to last monday
end_date – End of the timebracket as ‘DD.MM.YY’, defaults to next sunday
user_id – Fetch timetable for any student with the given Id
timeout (int) – Passed through to the request, increase if you request large amounts of data, as it might take longer to process than the default.
It is possible to fetch someone elses timetable if only their studentID is given, which can be acquired by running get_class_mates. Whether this is intentional or not is unclear, so this might be removed at any time
- Yield
- get_absences()¶
This function fetches a list of all absences and returns an Iterator containing objects from which you can get information very easily.
instance = Intranet(username, password) absenceIterator = instance.get_absences() for absence in absenceIterator: print("Name of teacher", absence.Lehrperson)
- Returns
- get_lesson_absence_data(lesson)¶
This function fetches the absence data corresponding to the
lessonpassed through You can also pass through a list oflessonobjects, and the function will return a list of the corresponding values
- get_class_mates()¶
This function fetches a list of each classMate and yields it back
- Yield
- set_homework_data(lesson, title, description)¶
- Parameters
- Raises
MissingPermission – Not enough permissions
Set homework data for passed through lesson, returns new homework data
- delete_homework_info(lesson)¶
- Parameters
lesson – Lesson object for which the absence should be deleted
- Raises
MissingPermission – Not enough permissions
Deletes all homework associated with that lesson
- get_additional_homework_info(lesson)¶
- Parameters
lesson – Lesson object for which the homework info should be fetched
The resource object¶
The absence object¶
This object contains attributes constructed directly from an intranet response, which contains multiple absence objects. Each absence object represents one absence and thereby its attributes. The following attributes are documented, but may change at any time without notice
- class absence¶
The lesson object¶
This object contains attributes constructed directly from an intranet response, which contains multiple timetable objects. Each absence object represents a lesson and thereby its attributes. The following attributes are documented, but may change at any time without notice, as the Intranet changes quite frequently. I will do my best to keep this documentation updated
- class lesson¶
-
- blockClassId: list[int]¶
used to represent multiple lessons together with each id being a lesson, empty if theres no associated lessons
Known IDs:
timetableEntryTypeId
timetableEntryType
timetableEntryTypeLong
timetableEntryTypeShort
1
lesson
lesson
lesson
11
substitution
canceled lesson
cancel
12
substitution
block substitution
block
15
substitution
holiday
holiday
16
lesson
modified lesson
modlesson
- message: str¶
Message by the Intranet. Some examples might be:
“Exkursion”
“Gesamtkonvent, Aula”
“Instrumentalunterricht findet statt!”
- halfClassLesson: unknown/None¶
- course: str¶
Long name of the course. Some examples are:
“Biologie, SP DjTj (4x )”
“Deutsch, GF DjTj (4x )”
“Mathematik, GF DjTj (4x )”
- subjectId: int¶
subjectIdsubjectName0
None
1
Deutsch
2
Französisch
4
Englisch
9
Mathematik
12
Chemie
13
Biologie
15
Geschichte
16
Einführung in Wirtschaft und Recht
23
Sport
24
Informatik
37
Klassenstunde
3, 5, 6, 7, 8, 10, 11, 14, 17-22, 25-36
unknown
- classId: list[int]¶
Id of the class. If it is a block, it contains multiple ids Can be mapped to className, as they directly correspond with each other.
ex:
classId“1618” belongs toclassName“4e”
- className: str¶
Name of the class. If there are multiple, they are sorted like “4a, 4b, 4c” Can be mapped to classId, as they directly correspond with each other.
ex:
classId“1618” belongs toclassName“4e”
- student: list[:class:`student`]¶
- hasExam: bool¶
Whether the lesson is an exam lesson. As of 16/09/21, this is false even if there is an exam. The only way to check whether there is an exam is if the string “(!)” is contained in lesson.title
- privileges: unknown/None¶
- resource: unknown/None¶
The student object¶
This object contains attributes constructed directly from an intranet response Each student object represents a student and thereby its attributes. The following attributes are documented, but may change at any time without notice
The ClassMate object¶
This object contains attributes constructed directly from an intranet response Each object represents a student and thereby its attributes. The following attributes are documented, but may change at any time without notice
- class ClassMate¶
The teacher object¶
This object contains attributes constructed directly from an intranet response Each object represents a student and thereby its attributes. The following attributes are documented, but may change at any time without notice
- class teacher¶