Unofficial API interface to the smartschool system.
Project description
Smartschool Parser
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.pyifiles - 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 authenticationPathCredentials,EnvCredentials,AppCredentials: Authentication methods
Academic Data
Courses,TopNavCourses: Course information and navigationResults: Grade and evaluation managementReports: Official academic reportsPeriods: Academic term information
Communication
MessageHeaders,Message: Email-like messaging systemAttachments: File attachment handlingBoxType,MessageLabel: Message organization
Planning & Schedule
FutureTasks: Assignment deadlines and tasksPlannedElements: Calendar events and activitiesSmartschoolLessons,SmartschoolHours: Daily schedules
Document Management
FileItem,FolderItem,InternetShortcut: Document typesDocumentOrFolderItem: 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
- Documentation: Check docstrings and type hints
- Issues: GitHub Issues
- API Changes: See CHANGELOG.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ab931a6226d14b77fc614842879d6a19470ef00ba32a1b864c0c3eb9bf36cfb
|
|
| MD5 |
14b1ae1e066a7765a8b76eaab645050d
|
|
| BLAKE2b-256 |
761d677a10840725739cba4a451bab9cd1d971d170b60de3305e9333552a1c88
|
Provenance
The following attestation bundles were made for smartschool-0.7.2.tar.gz:
Publisher:
release.yml on svaningelgem/smartschool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smartschool-0.7.2.tar.gz -
Subject digest:
6ab931a6226d14b77fc614842879d6a19470ef00ba32a1b864c0c3eb9bf36cfb - Sigstore transparency entry: 564994479
- Sigstore integration time:
-
Permalink:
svaningelgem/smartschool@5cc599309690f34461cdd13071c4f8ce0af9ece7 -
Branch / Tag:
refs/tags/0.7.2 - Owner: https://github.com/svaningelgem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5cc599309690f34461cdd13071c4f8ce0af9ece7 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03a9209e7e78f851b0c2c231c0c808c348729f429d115878695a425d77600345
|
|
| MD5 |
ba7fafdbd4ac8bd03b2d416e0d08bf68
|
|
| BLAKE2b-256 |
8d26e2cdf02b82662aead45a5d99ccbaaabc633b0c2e6d930f2b9724f1c863aa
|
Provenance
The following attestation bundles were made for smartschool-0.7.2-py3-none-any.whl:
Publisher:
release.yml on svaningelgem/smartschool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smartschool-0.7.2-py3-none-any.whl -
Subject digest:
03a9209e7e78f851b0c2c231c0c808c348729f429d115878695a425d77600345 - Sigstore transparency entry: 564994487
- Sigstore integration time:
-
Permalink:
svaningelgem/smartschool@5cc599309690f34461cdd13071c4f8ce0af9ece7 -
Branch / Tag:
refs/tags/0.7.2 - Owner: https://github.com/svaningelgem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5cc599309690f34461cdd13071c4f8ce0af9ece7 -
Trigger Event:
push
-
Statement type: