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 / CAS for an example with an ENT / CAS.


class pronotepy.ClientBase(pronote_url: str, username: str = '', password: str = '', ent: Optional[Callable] = None, qr_code: bool = False)#

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

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) T#

Login with QR code

Parameters
  • qr_code (dict) – JSON store in the QR code

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

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.

session_check() bool#

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

class pronotepy.Client(pronote_url: str, username: str = '', password: str = '', ent: Optional[Callable] = None, qr_code: bool = False)#

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

get_recipients() List[Recipient]#

Get recipients for new discussion

Returns

list of available recipients

Return type

List[Recipient]

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, qr_code: bool = False)#

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, qr_code: bool = False)#

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]