Clients#

Pronotepy currently implements three separate clients:

All of the clients extend a ClientBase class, which itself does not do much, and mainly just provides login and raw communication between pronotepy and the PRONOTE server.

When you make a new client instance it automatically logs in. The login process can raise a CryptoError exception, which usually means that the password was incorrect. You can check if the client is logged in using the ClientBase.logged_in attribute.

Example of client initialisation:

import pronotepy

try:
    client = pronotepy.Client(
        'https://demo.index-education.net/pronote/eleve.html',
        username='demonstration',
        password='pronotevs',
    )
    print(client.start_day)
except pronotepy.CryptoError:
    exit(1)  # the client has failed to log in

if not client.logged_in:
    exit(1)  # the client has failed to log in

Note

See ent for an example with an ENT / CAS.


class pronotepy.ClientBase(pronote_url: str, username: str = '', password: str = '', ent: Optional[Callable[[str, str], RequestsCookieJar]] = None, mode: str = 'normal', uuid: str = '')#

Base for every PRONOTE client. Provides login.

Parameters:
  • pronote_url (str) – URL of the server

  • username (str) –

  • password (str) –

  • ent (Callable) – Cookies for ENT connections

  • qr_code (bool) – internal option

start_day#

The first day of the school year

Type:

datetime.datetime

week#

The current week of the school year

Type:

int

logged_in#

If the user is successfully logged in

Type:

bool

username#
Type:

str

password#
Type:

str

pronote_url#
Type:

str

info#

Provides information about the current client. Name etc…

Type:

ClientInfo

last_connection#
Type:

datetime.datetime

keep_alive() _KeepAlive#

Returns a context manager to keep the connection alive. When inside the context manager, it sends a “Presence” packet to the server after 5 minutes of inactivity from another thread.

property periods: List[Period]#

Get all of the periods of the year.

Returns:

All the periods of the year

Return type:

List[Period]

post(function_name: str, onglet: Optional[int] = None, data: Optional[dict] = None) dict#

Preforms a raw post to the PRONOTE server. Adds signature, then passes it to _Communication.post

Parameters:
  • function_name (str) –

  • onglet (int) –

  • data (dict) –

Returns:

Raw JSON

Return type:

dict

classmethod qrcode_login(qr_code: dict, pin: str, uuid: str) T#

Login with QR code

The created client instance will have its username and password attributes set to the credentials for the next login using token_login().

Parameters:
  • qr_code (dict) – JSON contained in the QR code. Must have login, jeton and url keys.

  • pin (str) – 4-digit confirmation code created during QR code setup

  • uuid (str) – Unique ID for your application. Must not change between logins.

refresh() None#

Now this is the true jank part of this program. It refreshes the connection if something went wrong. This is the classical procedure if something is broken.

request_qr_code_data(pin: str) dict#

Requests data for a new login QR code. This data can be then used with qrcode_login().

Parameters:

pin (str) – Four digit pin to use for the QR code

session_check() bool#

Checks if the session has expired and refreshes it if it had (returns bool signifying if it was expired)

classmethod token_login(pronote_url: str, username: str, password: str, uuid: str) T#

Login with a password token. Used for logins after qrcode_login().

The created client instance will have its username and password attributes set to the credentials for the next login using token_login().

Parameters:
  • pronote_url (str) – URL of the server

  • username (str) –

  • password (str) – Password token received from the previous login

  • uuid (str) – Unique ID for your application. Must not change between logins.

class pronotepy.Client(pronote_url: str, username: str = '', password: str = '', ent: Optional[Callable] = None, mode: str = 'normal', uuid: str = '')#

Bases: ClientBase

A PRONOTE client.

Parameters:
  • pronote_url (str) – URL of the server

  • username (str) –

  • password (str) –

  • ent (Callable) – Cookies for ENT connections

property current_period: Period#

the current period

discussions(only_unread: bool = False) List[Discussion]#

Gets all the discussions in the discussions tab

export_ical(timezone_shift: int = 0) str#

Exports ICal URL for the client’s timetable

Parameters:

timezone_shift (int) – in what timezone should the exported calendar be in (hour shift)

Returns:

URL for the exported ICal file

Return type:

str

generate_timetable_pdf(day: Optional[date] = None, portrait: bool = False, overflow: int = 0, font_size: Tuple[int, int] = (8, 3)) str#

Generate a PDF timetable.

Parameters:
  • day (Optional[datetime.date]) – the day for which to create the timetable, the whole week is always generated

  • portrait (bool) – switches the timetable to portrait mode

  • overflow (int) –

    Controls overflow / formatting of lesson names.

    • 0: no overflow

    • 1: overflow to the same page, long names printed on the bottom

    • 2: overflow to a separate page

  • font_size (Tuple[int, int]) – font size restrictions, first element is the preferred font size, and second is the minimum

get_recipients() List[Recipient]#

Get recipients for new discussion

Returns:

list of available recipients

Return type:

List[Recipient]

get_teaching_staff() List[TeachingStaff]#

Get the teacher list

Returns:

list of teachers and other staff

Return type:

List[TeachingStaff]

homework(date_from: date, date_to: Optional[date] = None) List[Homework]#

Get homework between two given points.

Parameters:
  • date_from (datetime) – The first date

  • date_to (datetime) – The second date. If unspecified to the end of the year.

Returns:

Homework between two given points

Return type:

List[Homework]

information_and_surveys(date_from: Optional[datetime] = None, date_to: Optional[datetime] = None, only_unread: bool = False) List[Information]#

Gets all the information and surveys in the information and surveys tab.

Parameters:
lessons(date_from: Union[date, datetime], date_to: Optional[Union[date, datetime]] = None) List[Lesson]#

Gets all lessons in a given timespan.

Parameters:
Returns:

List of lessons

Return type:

List[Lesson]

menus(date_from: date, date_to: Optional[date] = None) List[Menu]#

Get menus between two given points.

Parameters:
  • date_from (datetime) – The first date

  • date_to (datetime) – The second date. If unspecified to the end of the year.

Returns:

Menu between two given points

Return type:

List[Menu]

new_discussion(subjet: str, message: str, recipients: List[Recipient]) None#

Create a new discussion

Parameters:
  • subjet (str) – subject of the message

  • message (str) – content of the message

  • recipients (List[Recipient]) –

class pronotepy.ParentClient(pronote_url: str, username: str = '', password: str = '', ent: Optional[Callable] = None, mode: str = 'normal', uuid: str = '')#

Bases: Client

A parent PRONOTE client.

Parameters:
  • pronote_url (str) – URL of the server

  • username (str) –

  • password (str) –

  • ent (Callable) – Cookies for ENT connections

children#

List of sub-clients representing all the children connected to the main parent account.

Type:

List[ClientInfo]

post(function_name: str, onglet: Optional[int] = None, data: Optional[dict] = None) dict#

Preforms a raw post to the PRONOTE server.

Adds signature, then passes it to _Communication.post

Parameters:
  • function_name (str) –

  • onglet (int) –

  • data (dict) –

Returns:

Raw JSON

set_child(child: Union[str, ClientInfo]) None#

Select a child

Parameters:

child (Union[str, ClientInfo]) – Name or ClientInfo of a child.

class pronotepy.VieScolaireClient(pronote_url: str, username: str = '', password: str = '', ent: Optional[Callable] = None, mode: str = 'normal', uuid: str = '')#

Bases: ClientBase

A PRONOTE client for Vie Scolaire accounts.

Parameters:
  • pronote_url (str) – URL of the server

  • username (str) –

  • password (str) –

  • ent (Callable) – Cookies for ENT connections

classes#

List of all classes this account has access to.

Type:

List[StudentClass]