Skip to main content

Unofficial API interface to the smartschool system.

Project description

Smartschool Parser

codecov

Unofficial Python library providing programmatic access to Smartschool's web platform. Access courses, documents, messages, results, agenda, and more through a clean, type-safe API.

Quick Start

Create credentials.yml with your Smartschool credentials:

username: your_username
password: your_password
main_url: your_school.smartschool.be
mfa: your_birthday_or_2fa_secret  # YYYY-mm-dd or Google Authenticator secret

# Optional: email configuration for scripts
email_from: me@myself.ai
email_to:
  - me@myself.ai
from smartschool import Smartschool, PathCredentials, Courses

session = Smartschool(PathCredentials())
for course in Courses(session):
    print(course.name)

Core Features

๐Ÿ“š Course Management

  • Courses: List all available courses with metadata
  • TopNavCourses: Navigation bar courses with full document access
  • Document Browser: Navigate course folders and download files
  • File Downloads: Support for all file types with automatic extension detection

๐Ÿ“Š Academic Information

  • Results: Retrieve grades and detailed evaluations with teacher feedback
  • Reports: Download official academic reports (PDF format)
  • Periods: Academic terms and grading periods
  • FutureTasks: Upcoming assignments and deadlines
  • PlannedElements: Scheduled assignments and activities from the planner

๐Ÿ’ฌ Communication

  • Messages: Complete inbox/outbox management with threading support
  • Attachments: Download and manage message attachments
  • Message Operations: Mark read/unread, archive, delete, apply labels

๐Ÿ“… Calendar & Schedule

  • SmartschoolLessons: Daily lesson schedules with detailed information
  • SmartschoolHours: Class period definitions and timings
  • SmartschoolMomentInfos: Detailed lesson content and assignments

๐Ÿ†˜ Support & Resources

  • StudentSupportLinks: Access to school support resources and links

Authentication Methods

File-based Credentials (Recommended)

from smartschool import Smartschool, PathCredentials

# Automatically searches for credentials.yml in common locations
session = Smartschool(PathCredentials())

Environment Variables

from smartschool import Smartschool, EnvCredentials

# Uses SMARTSCHOOL_USERNAME, SMARTSCHOOL_PASSWORD, etc.
session = Smartschool(EnvCredentials())

Direct Credentials

from smartschool import Smartschool, AppCredentials

creds = AppCredentials(
    username="your_username",
    password="your_password", 
    main_url="school.smartschool.be",
    mfa="your_birthday_or_2fa_secret"
)
session = Smartschool(creds)

Multi-Factor Authentication

  • Birthday verification: Use format YYYY-mm-dd
  • Google Authenticator: Requires pip install smartschool[mfa]

Advanced Usage Examples

Document Management & Downloads

from smartschool import TopNavCourses
from pathlib import Path

# Browse and download course documents
for course in TopNavCourses(session):
    print(f"๐Ÿ“š Course: {course.name}")
    
    for item in course.items:
        if isinstance(item, FileItem):
            # Download individual files
            target_dir = Path("downloads") / course.name
            item.download_to_dir(target_dir)
            print(f"  ๐Ÿ“„ Downloaded: {item.name}")
            
        elif isinstance(item, FolderItem):
            # Navigate folders recursively
            print(f"  ๐Ÿ“ Folder: {item.name}")
            for subitem in item.items:
                print(f"    - {subitem.name}")

Academic Results Analysis

from smartschool import Results

# Analyze academic performance
for result in Results(session):
    points = result.graphic.achieved_points
    total = result.graphic.total_points
    percentage = result.graphic.percentage
    
    print(f"๐Ÿ“Š {result.name}: {points}/{total} ({percentage:.1%})")
    print(f"   ๐Ÿ“… Date: {result.date}")
    print(f"   ๐Ÿ‘จโ€๐Ÿซ Teacher: {result.gradebookOwner.name.startingWithFirstName}")
    
    # Access detailed feedback
    if result.feedback:
        for fb in result.feedback:
            print(f"   ๐Ÿ’ฌ {fb.user.name.startingWithFirstName}: {fb.text}")

Message Management

from smartschool import MessageHeaders, Message, BoxType

# Process inbox messages
for header in MessageHeaders(session, box_type=BoxType.INBOX):
    if header.unread:
        # Get full message content
        full_message = Message(session, header.id).get()
        
        print(f"๐Ÿ“ง From: {full_message.from_}")
        print(f"   Subject: {full_message.subject}")
        print(f"   Body: {full_message.body[:100]}...")
        
        # Download attachments if present
        if header.attachment:
            from smartschool import Attachments
            for attachment in Attachments(session, header.id):
                content = attachment.download()
                Path(f"attachments/{attachment.name}").write_bytes(content)

Task & Assignment Tracking

from smartschool import FutureTasks, PlannedElements
from datetime import datetime

# Track upcoming assignments
print("๐Ÿ“‹ Upcoming Tasks:")
for day in FutureTasks(session):
    print(f"\n๐Ÿ“… {day.date}")
    for course in day.courses:
        for task in course.items.tasks:
            print(f"  ๐Ÿ“ {course.course_title}: {task.label}")
            print(f"     {task.description}")

# Check planned activities
print("\n๐Ÿ“… Planned Activities:")
for element in PlannedElements(session):
    start_time = element.period.dateTimeFrom
    course_names = [c.name for c in element.courses]
    
    print(f"๐ŸŽฏ {element.name}")
    print(f"   ๐Ÿ“… {start_time.strftime('%Y-%m-%d %H:%M')}")
    print(f"   ๐Ÿ“š Courses: {', '.join(course_names)}")

Schedule Information

from smartschool import SmartschoolLessons, SmartschoolHours
from datetime import date, timedelta

# Get tomorrow's schedule
tomorrow = date.today() + timedelta(days=1)
lessons = SmartschoolLessons(session, timestamp_to_use=tomorrow)

for lesson in lessons:
    hour_details = lesson.hour_details
    
    print(f"๐Ÿ• {hour_details.start}-{hour_details.end}: {lesson.course}")
    print(f"   ๐Ÿ“ Room: {lesson.classroom}")
    print(f"   ๐Ÿ‘จโ€๐Ÿซ Teacher: {lesson.teacher}")
    if lesson.subject:
        print(f"   ๐Ÿ“ Subject: {lesson.subject}")

Utility Scripts

The package includes several command-line utilities:

Document Management

# Interactive document browser
smartschool_browse_docs

# Bulk download all course documents  
smartschool_download_all_documents

Automated Notifications

# Email notifications for new results
smartschool_report_on_results

# Daily task summaries
smartschool_report_on_future_tasks

# Planned assignment alerts
smartschool_report_on_planned_tasks

Error Handling

from smartschool.exceptions import (
    SmartSchoolException,
    SmartSchoolAuthenticationError,
    SmartSchoolDownloadError,
    SmartSchoolParsingError
)

try:
    session = Smartschool(PathCredentials())
    results = list(Results(session))
except SmartSchoolAuthenticationError:
    print("โŒ Login failed - check your credentials")
except SmartSchoolDownloadError as e:
    print(f"โŒ Download failed: {e}")
except SmartSchoolParsingError as e:
    print(f"โŒ Data parsing error: {e}")
except SmartSchoolException as e:
    print(f"โŒ General API error: {e}")

Development Setup

git clone https://github.com/svaningelgem/smartschool.git
cd smartschool

# Using conda/mamba (recommended)
mamba create -n smartschool python=3.11
mamba activate smartschool

# Install with poetry
pip install poetry
poetry install

# Run tests
poetry run pytest

# Code formatting and linting
poetry run ruff format .
poetry run ruff check .

Development Tools

  • Stub Generation: ./restub - Auto-generates .pyi files
  • Testing: pytest with coverage reporting
  • Linting: ruff for formatting and code quality
  • CI/CD: GitHub Actions with automated PyPI publishing

API Reference

Core Classes

  • Smartschool: Main session handler with automatic authentication
  • PathCredentials, EnvCredentials, AppCredentials: Authentication methods

Academic Data

  • Courses, TopNavCourses: Course information and navigation
  • Results: Grade and evaluation management
  • Reports: Official academic reports
  • Periods: Academic term information

Communication

  • MessageHeaders, Message: Email-like messaging system
  • Attachments: File attachment handling
  • BoxType, MessageLabel: Message organization

Planning & Schedule

  • FutureTasks: Assignment deadlines and tasks
  • PlannedElements: Calendar events and activities
  • SmartschoolLessons, SmartschoolHours: Daily schedules

Document Management

  • FileItem, FolderItem, InternetShortcut: Document types
  • DocumentOrFolderItem: Union type for navigation

Support

  • StudentSupportLinks: School support resources

Requirements

  • Python: 3.11+
  • Core Dependencies: requests, beautifulsoup4, pydantic, pyyaml, logprise
  • Optional: pyotp (for 2FA support)

License

GNU General Public License v3.0

Contributing

Contributions welcome! Please ensure:

  • Tests pass: poetry run pytest
  • Code is formatted: poetry run ruff format .
  • Linting passes: poetry run ruff check .
  • Type stubs are updated: ./restub

Support

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

smartschool-0.7.2.tar.gz (48.6 kB view details)

Uploaded Source

Built Distribution

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

smartschool-0.7.2-py3-none-any.whl (56.9 kB view details)

Uploaded Python 3

File details

Details for the file smartschool-0.7.2.tar.gz.

File metadata

  • Download URL: smartschool-0.7.2.tar.gz
  • Upload date:
  • Size: 48.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for smartschool-0.7.2.tar.gz
Algorithm Hash digest
SHA256 6ab931a6226d14b77fc614842879d6a19470ef00ba32a1b864c0c3eb9bf36cfb
MD5 14b1ae1e066a7765a8b76eaab645050d
BLAKE2b-256 761d677a10840725739cba4a451bab9cd1d971d170b60de3305e9333552a1c88

See more details on using hashes here.

Provenance

The following attestation bundles were made for smartschool-0.7.2.tar.gz:

Publisher: release.yml on svaningelgem/smartschool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smartschool-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: smartschool-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 56.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for smartschool-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 03a9209e7e78f851b0c2c231c0c808c348729f429d115878695a425d77600345
MD5 ba7fafdbd4ac8bd03b2d416e0d08bf68
BLAKE2b-256 8d26e2cdf02b82662aead45a5d99ccbaaabc633b0c2e6d930f2b9724f1c863aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for smartschool-0.7.2-py3-none-any.whl:

Publisher: release.yml on svaningelgem/smartschool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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