Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
Lorenzo Leonardini edited this page Jul 17, 2020 · 4 revisions

Note

Both the library and the docs have been made in a couple of hours of boredom. So don't expect great code quality and if you don't understand some docs look at the example.py file.

Getting Started

The whole thing revolves around an instance of the class Esse3API (located in the module api). To create it you need to pass in the endpoint URL, an username, and a password:

import Esse3Api.api as esse3

api = esse3.Esse3API('https://example.com/e3rest/api/', user, password)

Many known endpoints are already provided via the endpoint module. You can access them like this:

import Esse3Api.endpoint

api = esse3.Esse3API(Esse3Api.endpoint.endpoints['UNIPI']['url'], user, password)

You can also prompt the user to select their University:

url = esse3.Esse3Api.endpoint.prompt()

Once the Esse3API object is created, it automatically tries to login to the API. If it fails, an exception is risen.

Personal data

Some basic student data can be retrieved via the Student object, accessible with the Esse3API.user() method. This class is responsible for storing all the career data, but it is advisable to retrieve it with the main Esse3API class.

To obtain complete information about the student, Esse3API.personal_data() can be called. The retrieved object contains:

variable type
name string
surname string
codice_fiscale string
data_nascita string
comune_nascita string
nazione_nascita string
email string
email_ateneo string
userId int
sesso string
domicilio Address
residenza Address

The Address class contains:

variable type
cap int
comune string
comune_sigla string
nazione string
via string
civico int
telefono int

Career

Every student has an array of Carriera objects (basically one for each degree). The default selected career is the active one, but it can be changed passing the index of the new desired active career with Esse3API.seleziona_carriera(index). If you want the complete collection of careers you can get it with Esse3API.carriera_completa(), if you want the active career you use Esse3API.carriera().

Keep in mind that with 'active career' we intend the career from which you are retrieving data. You cannot obviously change the career in the db.

The Carriera object contains:

variable type
corso_di_studi string
matricola int
matId int
motStastuDes string
staMatDes string
staStuDes string
stuId int
anno_accademico string
anno_corso int
dataImm string
dataIscr string
dataMod string

Libretto

You can get information about the exams from the current career with Esse3API.libretto(). The data contained is:

variable type
esami list(Esame)
esami_per_anno list(Esame)

The Esame object contains

variable type
anno_frequenza string
nome string
codice string
anno_corso int
cfu float
tipo_esame string
stato string
anno_superamento string
data_esame string
voto float
lode int

Taxes

Information about current career's taxes can be retrieved with Esse3API.tasse()

variable type
importo_dovuto float
semaforo string

Profile picture

Esse3API.propic() returns raw image data from requests. It can be used to save the profile picture to a file like this:

with open('propic', 'wb') as f:
    api.propic().decode_content = True
    shutil.copyfileobj(api.propic(), f) 
Clone this wiki locally