Skip to main content

A python library for accessing your Edupage account

Project description

Disclaimer

I do not have the energy to update this project. I can make bug-fixes or some small feature updates from time to time, but I am fed up with python's weak typing.

edupage-api

CodeFactor

This python library allows easy access to Edupage. This is not a Selenium web scraper. It makes requests directly to Edupage's endpoints and parses the HTML document.

If you find any issue with this code, it doesn't work, or you have a suggestion please let me know by opening an issue! If you, even better have fixed the issue, added a new feature or made something work better please open a pull request!

Installing

You can install this library with pip:

pip install edupage-api

Usage

Login

You can log in easily, works with any school:

from edupage_api import Edupage, BadCredentialsException, LoginDataParsingException


edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")

try:
    edupage.login()
except BadCredentialsException:
    print("Wrong username or password!")
except LoginDataParsingException:
    print("Try again or open an issue!")

Get timetable for a given date

Check all available timetables:

from edupage_api import Edupage

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")
edupage.login()

# Get dates for all available timetables
dates = edupage.get_available_timetable_dates()

print(dates) # ['2021-02-03', '2021-02-04']

Get the timetable for a date

from edupage_api import Edupage, EduDate

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")
edupage.login()

# Get today's date
today = EduDate.today() # '2021-02-03'

timetable = edupage.get_timetable(today) # returns EduTimetable

# Get first lesson
first_lesson = timetable.get_first_lesson()

# The starting and ending time of the first lesson
start_time = first_lesson.length.start
end_time = first_lesson.length.end

print(start_time)
print(end_time)

# Get yesterday date
yesterday = EduDate.yesterday_this_time() # '2021-02-04'
print(yesterday)

# This will return None, because the timetable from yesterday is not available
timetable_for_yesterday = edupage.get_timetable(yesterday)
print(timetable_for_yesterday)

Get lesson for a given time

from edupage_api import Edupage, EduDate, EduTime

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")
edupage.login()

# Timetable for today
timetable = edupage.get_timetable(EduDate.today())

# Get current time
current_time = EduTime.now()

current_lesson = timetable.get_lesson_at_time(current_time)

print(current_lesson)

Get next lesson for a given time

from edupage_api import Edupage, EduDate, EduTime

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")
edupage.login()

# Timetable for today
timetable = edupage.get_timetable(EduDate.today())

# Get current time
current_time = EduTime.now()

next_lesson = timetable.get_next_lesson_at_time(current_time)

print(next_lesson)

The EduLesson class provides some information about the lesson:

EduLesson:

  • period: The order of period in timetable (e.g. 1).
  • name: The subject of this lesson.
  • teacher: The teacher that will teach this lesson
  • classroom: The classroom number where the lesson will be.
  • length: EduLength –> The length (start and end times) of the lesson.
  • online_lesson_link: A string with link to the online lesson. If this lesson is not online, online_lesson_link is None.

Tell edupage that you are on an online lesson

Useful for automating your presence, because you don't actually have to be on the lesson. You can tell edupage that you are on the current lesson like this:

from edupage_api import Edupage, LessonUtil

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")
edupage.login()

timetable = edupage.get_timetable(EduDate.today())
next_lesson = timetable.get_next_lesson_at_time(EduTime.now())

if LessonUtil.is_online_lesson(next_lesson):
    next_lesson.sign_into_lesson(edupage)
    print("You are now 'present' on the next lesson!")
else:
    print("The next lesson is not an online lesson!")

Get news from the webpage

Thanks to how Edupage's message system works, you can get recent news from the webpage like this:

from edupage_api import Edupage

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")
edupage.login()

# Note: if you are not logged in or there was an error, get_news returns None
news = edupage.get_news() # returns a list of EduNews

for message in news:
    print(str(news))

Get a list of students

This is an edupage-curated list of students. When students enter the school, they get assigned a number. If anybody changes school, leaves or anything happens with any student, the numbers don't change. It just skips the number.

from edupage_api import Edupage, EduStudent

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")
edupage.login()

# Note: This list doesn't have to be sorted!
students = edupage.get_students()

# Sort the list by student numbers
students.sort(key = EduStudent.__sort__)

for student in students:
    print(f"{student.number_in_class}: {student.fullname}")

Get a list of teachers

This list is not sorted in any way and this library doesn't provide a way to sort it.

from edupage_api import Edupage

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")

# Note: This list is not sorted and you cannot sort it with EduStudent.__sort__!
teachers = edupage.get_teachers()

for teacher in teachers:
    print(str(teacher))

Get homework

from edupage_api import Edupage

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")  
edupage.login()

homework = edupage.get_homework()

for hw in homework:
    print(hw.due_date)

Homework, other than its title and description, provides some more information:

EduHomework

  • due_date: EduDate –> When the homework is due
  • subject: The subject which this homework is from
  • groups: If this subject is divided into groups, the target should be here. Needs testing
  • title: The title of the homework message. This is usually what you in a notification in the Edupage app.
  • description: A detailed description of the homework. (Usually is blank)
  • event_id: A internal Edupage ID, which can be used to find the event corresponding to this homework. Useless for now.
  • datetime_added: EduDateTime –> A date and time when this homework was assigned.

Sending messages

You can send a message to one or multiple people when you have an object that extends EduPerson

from edupage_api import Edupage, EduStudent

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")
edupage.login()

for student in students:
    if student.fullname == "John Smith":
        # Ignore the attachments parameter, for some reason attachments do not work
        edupage.send_message(student, "Hello John!")

Upload a file to Edupage's cloud

The file will be hosted forever (and for free) on Edupage's servers. The file is tied to your user account, but anybody with a link can view it.

Anyway, Edupage limits file size to 50 MB and the file can have only some extensions. All supported file extensions could be found on this Edupage help site.

from edupage_api import Edupage, EduStudent
from edupage_api.cloud import EduCloud

edupage = Edupage("Subdomain (Name) of your school", "Username or E-Mail", "Password")
edupage.login()

f = open("image.png", "rb")

uploaded_file = EduCloud.upload_file(edupage, f)
link = uploaded_file.get_url(edupage)

print(link)

Upcoming features

  • Lunches
  • Grades
  • Reading your own notifications
  • Connecting to the online lessons (with your presence being acknowledged by Edupage)
  • Uploading (and hosting) files on the Edupage cloud (if possible)
  • Writing messages to other students/teachers
  • Make this library available through PyPi

Feel free to suggest any other features! Just open an issue with the Feature Request tag.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edupage_api-0.9.7.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edupage_api-0.9.7-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file edupage_api-0.9.7.tar.gz.

File metadata

  • Download URL: edupage_api-0.9.7.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for edupage_api-0.9.7.tar.gz
Algorithm Hash digest
SHA256 136f2ada5275b2b1fad4173dfa967b87295c261c26678cccc064303a4258d527
MD5 f8395382abd378b6931796d703747fa7
BLAKE2b-256 3b9d6fb644f550e63a338bd0917b9bcfbcbb98ac253ec446a77d0ccc9635d6e3

See more details on using hashes here.

File details

Details for the file edupage_api-0.9.7-py3-none-any.whl.

File metadata

  • Download URL: edupage_api-0.9.7-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for edupage_api-0.9.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f00c3dd17f7b0bf52d7b2d87add0d90815eb9d45726426bf176350e728360960
MD5 974ee535752c54ecc3844388c77f0a74
BLAKE2b-256 4b4bbf75c5c7cfd63894f601d97ec1d7f2bd4e8658fc51fe2fd3b220bb5a9b38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page