fenixedu

FenixEdu API SDK for python


License
Other
Install
pip install fenixedu==1.0.0

Documentation

fenix_python_sdk

Installation

$ pip install fenixedu

Usage

Instantiating the client

  • Import python sdk
import fenixedu

Instantiating a configuration object

Using a configuration file
  • Clone this repository or just download fenixedu.sample.ini file

  • Copy file fenixedu.sample.ini to a new one named 'fenixedu.ini' or with another name if you want

$ cp fenixedu.sample.ini FILENAME
  • Edit the file according to your application info

  • Instantiate a configuration object using the file

config = fenixedu.FenixEduConfiguration.fromConfigFile('FILENAME')
  • If no FILENAME is provided it will use 'fenixedu.ini'
Without a configuration file
config = fenixedu.FenixEduConfiguration('CLIENT_ID', 'REDIRECT_URI', 'CLIENT_SECRET', 'BASE_URL')

Instantiating the client

  • Instantiate an API client object in your source code
client = fenixedu.FenixEduClient(config)

Authentication

  • Get the authentication URL
url = client.get_authentication_url()
  • Redirect your user to that URL

  • If the user authorizes your application he will be redirected to an URL like this:

redirect_uri?code=CODE
  • Get the code parameter in URL and get an object with the user details:
user = client.get_user_by_code('CODE')
  • It will request an access token and returns no errors if everything is fine

  • This user object now can be used to make requests that belong to the private scope like this one:

person = client.get_person(user)

Examples of usage

Get degrees

degrees = client.get_degrees()

Get spaces

spaces = client.get_spaces()

Get information about the user

person = client.get_person(user)

Get user's classes calendar

classes = client.get_person_calendar_classes(user)

Get user's payments

payments = client.get_person_payments(user)

Full endpoint list

  • '[x]' - Optional parameters

  • All endpoints in FenixEdu API have a method in this SDK

  • Mapping between FenixAPISingleton api methods and original API endpoints

  • API endpoint -> SDK FenixAPISingleton Methods

Public methods

  • GET /about -> get_about

  • GET /academicterms -> get_academic_terms

  • GET /courses/{id} -> get_course(id)

  • GET /courses/{id}/evaluations -> get_course_evaluations(id)

  • GET /courses/{id}/groups -> get_course_groups(id)

  • GET /courses/{id}/schedule -> get_course_schedule(id)

  • GET /courses/{id}/students -> get_course_students(id)

  • GET /degrees -> get_degrees([year])

  • GET /degrees/{id} -> get_degree(id, [year])

  • GET /degrees/{id}/courses -> get_degree_courses(id, [year])

  • GET /spaces -> get_spaces()

  • GET /spaces/{id} -> get_space(id,[day])

Private methods (You need to get an access token before calling one of these methods)

  • GET /person -> get_person(user)

  • GET /person/calendar/classes -> get_person_classes_calendar(user)

  • GET /person/calendar/evaluations -> get_person_evaluations_calendar(user)

  • GET /person/courses -> get_person_courses(user, [academicTerm])

  • GET /person/evaluations -> get_person_evaluations(user)

  • GET /person/payments -> get_person_payments(user)

  • PUT /person/evaluations/{id} -> enrol_in_evaluation(user, id, [enrol_action])

  • GET /person/curriculum -> get_person_curriculum(user)

More info about all available endpoints in FenixEdu API website