Package: pyToledo
pytoledopytoledo is a Python library to interact with the common virtual learning environment for the Association KU Leuven a.k.a Toledo.v3.0.0 adds support for KU Leuven Authenticator, which is now mandatory for all studentsv3.1.0 adds the ability to query Vives Plus endpoints, please note that this might not work for Luca, Odisee, Thomas More and UCLL students!MotivationMy goal was to provide an easy way to interact with the various KU Leuven API endpoints.This library reproduces the Toledo portal login flow and returns a requests Session object that keeps track of your cookies and headers.With this basic session object you can query these endpoints:EnrollmentsUpcoming coursesEvents (messages and updates)Optionally:Extend this basic session with kuloket cookies. This allows you to query the following endpoints:ScheduleExtend this basic session with toledo dashboard cookies. This allows you to query the following endpoints:Todo (tasks and tests)Create a Vives Plus session. This allows you to query the following endpoints:Schedule (dynamic)Student informationNoticesDashboardGood to know:Bypassing KU Leuven Authenticator prompts is possible by exporting and re-using your Vives Plus authorization token.Data will always be returned as JSON via stdout. You can redirect the output to any file using '>'.Teacher accounts (u) are not supported!InstallationpipUse the package managerpipto install pytoledo.pipinstallpytoledo--upgradeUsageAs a packageToledofromtoledoimportportalfromtoledoimportkuloketfromtoledoimportdashboardfromtoledoimportapi# Create a portal session objectportal_session=portal.create_session_object(user='',password='')# Optionally extend the portal session with kuloket cookiesextendend_session=kuloket.extend_session(portal_session=portal_session)# and/or dashboard cookiesextendend_session=dashboard.extend_session(portal_session=portal_session)# Create an api objecttoledo_api=api.create_api_object(session=extended_session)Vives Plusfromtoledoimportvivesplusfromtoledoimportapi# Create a Vives Plus session object from username & passwordvivesplus_session=vivesplus.create_vivesplus_session_object(user='',password='',)# or from authorization token or filevivesplus_session=vivesplus.create_vivesplus_session_object(authorization='')# Create an api objectvivesplus_api=api.create_vivesplus_api_object(session=vivesplus_session)ExamplesToledoEnrollments/courses# returns all your courses in JSONtoledo_api.get_enrollments()Upcoming courses# returns your upcoming courses (for today) in JSONtoledo_api.get_upcoming()Events (messages & updates)# returns your messages in JSONtoledo_api.get_events(type='message')# returns your updates in JSONtoledo_api.get_events(type='update')Todo (tasks & tests)# returns your tasks in JSONtoledo_api.get_to_do(type='task')# returns your tests in JSONtoledo_api.get_to_do(type='test')Schedule# returns your schedule in JSONtoledo_api.get_schedule()Vives PlusExport and re-use authorization token# login using username and passwordvivesplus_session=vivesplus.create_vivesplus_session_object(user='',password='',)# Create an api objectvivesplus_api=api.create_vivesplus_api_object(session=vivesplus_session)# returns your authorization token in JSONauthorization=vivesplus_api.get_authorization_token()# login using your authorization tokenvivesplus_session=vivesplus.create_vivesplus_session_object(authorization=authorization['token'])Schedule# returns your schedule in JSONvivesplus_api.get_schedule(start_date='2023-06-14',end_date='2023-06-22')Student information# returns your student information in JSONvivesplus_api.get_student_info()Dashboard# returns your dashboard in JSONvivesplus_api.get_dashboard()Notices# returns your notices in JSONvivesplus_api.get_notices()As a scriptToledooptionalarguments:-h,--helpshowthishelpmessageandexit--enrollments,-enretrieveallyourenrollments--todo{task,test},-td{task,test}retrieveyourto-dolist(tasksortests)--upcoming,-upretrieveyourupcomingcourses--events{message,update},-ev{message,update}retrieveyourrecentevents(messagesorupdates)--schedule,-scretrieveyourschedule--rnumberRNUMBER,-rnRNUMBERyourpersonalrnumber--passwordPASSWORD,-pwPASSWORDyourpassword--silent,-ssurpressoutputVives Plusoptionalarguments:-h,--helpshowthishelpmessageandexit--schedule,-scretrieveyourschedule--student-info,-siretrieveyourstudentinformation--dashboard,-dbretrieveyourdashboard--notices,-noretrieveyournotices--get-authorization-token,-gatretrieveyourvivesplusauthorizationtokenasaJSONfile--set-authorization-tokenJSONTOKENFILE,-satJSONTOKENFILEsetyourvivesplusauthorizationtokenbyprovidingaJSONfile--rnumberRNUMBER,-rnRNUMBERyourpersonalrnumber--passwordPASSWORD,-pwPASSWORDyourpassword--silent,-ssurpressoutputExamplesToledoEnrollments/coursespython-mtoledotoledo--enrollments--rnumberyourrrnumber--passwordyourpasswordUpcoming coursespython-mtoledotoledo--upcoming--rnumberyourrrnumber--passwordyourpasswordEvents (messages & updates)# Messagespython-mtoledotoledo--eventsmessage--rnumberyourrrnumber--passwordyourpassword# Updatespython-mtoledotoledo--eventsupdate--rnumberyourrrnumber--passwordyourpasswordTodo (tasks & tests)# Taskspython-mtoledotoledo--todotask--rnumberyourrrnumber--passwordyourpassword# Testspython-mtoledotoledo--todotest--rnumberyourrrnumber--passwordyourpasswordSchedulepython-mtoledotoledo--schedule--rnumberyourrrnumber--passwordyourpasswordVives PlusExport and re-use authorization token# Exportpython-mtoledovivesplus--get-authorization-token--rnumberyourrrnumber--passwordyourpassword# Re-usepython-mtoledovivesplus--set-authorization-tokenvivesplus_authorization_token_<yourrnumber>.json...anyotheroptionSchedulepython-mtoledovivesplus--set-authorization-tokenvivesplus_authorization_token_<yourrnumber>.json--schedule'2023-06-14''2023-06-22'Student informationpython-mtoledovivesplus--set-authorization-tokenvivesplus_authorization_token_<yourrnumber>.json--student-infoDashboardpython-mtoledovivesplus--set-authorization-tokenvivesplus_authorization_token_<yourrnumber>.json--dashboardNoticespython-mtoledovivesplus--set-authorization-tokenvivesplus_authorization_token_<yourrnumber>.json--noticesTODODocumentationTestsContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.LicenseGNU GPLv3