Main reference#

LanisClient#

class LanisClient(authentication: LanisAccount | LanisCookie | None, ad_header: Headers = None)#

The interface between python and Schulportal Hessen.

Use authenticate() to use this interface.

Parameters:
  • authentication (LanisAccount or LanisCookie or None) –

    1. A Lanis account with its username and password, and a school id or school name and city in School.

    2. Cookies with authentication data (school id and session id) in LanisCookie for instantly interacting with Lanis. You can obtain this during a session with authentication_cookies.

    3. If None it will use the session.json, like for the 30-days session or last session (100min), when no session.json exists, it will return ForceNewAuthenticationError.

  • ad_header (httpx.Headers, default {"user-agent": ....}) – Send custom headers to Lanis. Primarily used to send a custom user-agent.

Properties#

property LanisClient.authentication_cookies: LanisCookie#

Return LanisCookie with the authentication data (school id and session id) if authenticated. You can use this to authenticate with Lanis instantly.

General functions#

authenticate(self, session_type: SessionType = SessionType.NORMAL, force: bool = False) None#

Log into the school portal and sets the session id in the auth_cookies.

Parameters:
  • force (bool, optional) – If True it always makes a new session with Lanis, by default False

  • session_type (SessionType, optional by default SessionType.NORMAL) – Which session to create. There are two session types: NORMAL and LONG. The long session is 30-days long (angemeldet bleiben option) and needs no password or name to be put in afterwards. It does not force a new session!

Note

Supports only the new system (login.schulportal.hessen.de). More at https://support.schulportal.hessen.de/knowledgebase.php?article=1087.

logout(self) None#

Log out.

Note

For closing the current LanisClient use close()

close(self) None#

Close the client and saves to session.json; you need to do this.

Authentication types#

class School#

Alternative to school id for authentication.

Parameters:
  • name (str) – Full school name

  • city (str) – City name sometimes with abbreviations or fully written.

class LanisAccount#

An attrs class to authenticate with this library. It’s a normal Lanis user account.

Parameters:
  • name (str or School) – School id or School class.

  • username (str) – Format: firstname.lastname

  • password (str) – The password.

class LanisCookie#

An attrs class to authenticate with this library. It’s a cookie with the school id and session id.

Parameters:
  • school_id (str) – The id of the school.

  • session_id (str) – The id or how Lanis calls it sid of a session.

Note

Use LanisClient.authentication_cookies from a previous session to get LanisCookie for the next session.

enum SessionType(value)#

Used in authenticate() to indicate which session type you want.

  • NORMAL, used to get a normal session which lasts 100min.

  • LONG, used to get a 30-days (angemeldet bleiben option).

Valid values are as follows:

NORMAL = <SessionType.NORMAL: 1>#
LONG = <SessionType.LONG: 2>#

Get all schools#

Functions#

get_schools(self) list[dict[str, str]]#

Return all schools with their id, name and city.

Returns:

JSON

Return type:

list[dict[str, str]]

Getting the Substitution plan#

Functions#

get_substitution_plan(self) SubstitutionPlan#

Return the whole substitution plan of the current day.

Return type:

SubstitutionPlan

Types#

class SubstitutionPlan#

The substitution plan page in a data type.

Parameters:
  • date (datetime.datetime) – Date of the substitution plan.

  • substitutions (list[Substitution]) – The individual substitutions.

  • info (str) – info is the box with the title “Allgemein” that exists sometimes.

class Substitution#

The individual substitution data (table row).

Parameters:
  • substitute (str) – Often abbreviation of the substitute.

  • teacher (str) – Often abbreviation of the teacher.

  • hours (str) – When is it in school hours.

  • class_name (str) – Name of the classes.

  • subject (str) – The subject is rarely given.

  • room (str) – Room of the substitution.

  • notice (str) – More info about the substitution.

Getting the Calendar#

Functions#

get_calendar(self, start: datetime, end: datetime, json: bool = False) Calendar#

Return all calendar events between the start and end date.

Parameters:
  • start (datetime.datetime) – Start date

  • end (datetime.datetime) – End date

  • json (bool, default False) – Returns Json with every property instead of the limited CalendarData. Defaults to False.

Returns:

Calendar with Event or Json.

Return type:

Calendar

get_calendar_of_month(self) Calendar#

Use the get_calendar() function but only returns all events of the current month.

Returns:

Calendar with Event

Return type:

Calendar

Types#

class Calendar#

The calendar page in a data type.

Parameters:
  • start (datetime.datetime) – Start date and time of the calendar.

  • end (datetime.datetime) – End date and time of the calendar.

  • events (list[Calendar] or list[dict[str, any]]) – Use events to access the most important properties. It is either in Calendar or JSON format. When it is in JSON format it has all, including unnecessary ones, properties.

class Event#

Each calendar cell “event” data.

Parameters:
  • title (str) – Name of the event.

  • description (str) – Description of the event.

  • place (str) – Place of the event.

  • start (datetime.datetime) – Start day and time of the event.

  • end (datetime.datetime) – End day and time of the event. Could also exceed the calendars start and end.

  • whole_day (bool) – Does it happen the whole day or only between a specific time.

  • responsible (Callable) – The person who is responsible for this event. You need to call this first, then it returns (hopefully) a string.

Getting all tasks#

Functions#

get_tasks(self) list[Task]#

Return all tasks from the “Mein Unterricht” page with downloads in .zip format.

Return type:

list[TaskData]

Types#

class Task#

The “Mein Unterricht” page in a data type. Expect many parameters to be None.

Parameters:
  • title (str) – Name of the task.

  • date (datetime.datetime) – Creation date of the task.

  • subject_name (str) – Subject of the task often with the class name and weird ids at the end, like “Chemie 7GA (071CH01-GYM)”

  • teacher (str) – Abbreviation of the teacher.

  • description (str) – Optional description of the task.

  • details (str) – details is the blue button with a comment symbol that sometimes appears.

  • attachment (list[str]) – List of the attachments names.

  • attachment_url (str) – Download link to a zip file containing all attachments.

Getting conversations#

Functions#

get_conversations(self, number: int = 5) list[Conversation]#

Return conversations from the “Nachrichten - Beta-Version”.

Parameters:

number (int, optional) – The number of conversations to return, by default 5. To get all conversations use -1 but this will take a while and spam Lanis servers.

Returns:

The conversations in Conversation.

Return type:

list[Conversation]

Types#

class Conversation#

A conversation.

Parameters:
  • id (str) – The Uniquid (as Lanis calls it) of a conversation.

  • title (str) – The title.

  • teacher (str) – The teacher in full name.

  • creation_date (str) – When the conversation was created.

  • newest_date (str) – When the newest comment was created.

  • unread (bool) – If the user already marked it as read.

  • special_receivers (list[str]) – Often these are groups of specific people, like Alle SuS or special People, like Admin.

  • receivers (list[str]) – People with their full name and sometimes class.

  • content (str) – The content.

  • comments (None) – Currently always None because it wasn’t implemented yet.

Getting all web applets#

Functions#

get_apps(self) list[App]#

Get all web applets from Lanis, not only supported ones.

Returns:

A list of App.

Return type:

list[App]

get_folders(self) list[Folder]#

Get all web folders from Lanis.

Returns:

A list of Folder.

Return type:

list[Folder]

get_available_apps(self) list[str]#

Get all supported web applets by this library which are also supported by the Lanis of the user.

Returns:

A list of the supported applets.

Return type:

list[str]

get_app_availability(self, app_name: str) bool#

Check if one of these apps: Kalender, Mein Unterricht, Nachrichten - Beta-Version, Vertretungsplan is supported by the school.

Parameters:

app_name (str) – The applet name.

Return type:

bool

Types#

class Folder#

A Lanis web folder.

Parameters:
  • name (str) – The name.

  • symbol (str) – A symbol which represents this applet. Lanis uses Font Awesome and Glyphicons for this.

  • colour (str) – The colour of these small top bars which you can see on Lanis.

class App#

A Lanis web applet.

Parameters:
  • name (str) – The name.

  • colour (str) – The colour which you can see on Lanis.

  • folder (list of Folder) – The groups, category, folder or how you want to call it of the app. You can see it on the index page of Lanis.

  • link (str) – The full Lanis link.

  • symbol (str) – A symbol which represents this applet. Lanis uses Font Awesome and Glyphicons for this.