A Python library for accessing the Bakalapi timetable API
Project description
Bakalapi Python Library
A Python library for accessing the Bakalapi timetable API. This library provides a simple interface to query timetable information by teacher, room, or class.
Installation
Install from local directory
If you have the source code, you can install it directly:
pip install .
Or in development mode (editable install):
pip install -e .
Install from PyPI (if published)
If the package is published to PyPI, you can install it with:
pip install bakalapi
Development Installation
For development, you can also install dependencies separately:
pip install -r requirements.txt
Usage
Basic Usage
from bakalapi import BakalapiClient
# Create a client instance
client = BakalapiClient()
# Get timetable by teacher
timetable = client.get_teacher_timetable("Hana Jaitnerová")
print(f"Found {len(timetable.timetable)} entries")
for entry in timetable.timetable:
print(f"{entry.date} {entry.time}: {entry.subject} - {entry.class_name}")
# Get timetable by room
timetable = client.get_room_timetable("a1")
print(f"Room a1 has {len(timetable.timetable)} scheduled entries")
# Get timetable by class
timetable = client.get_class_timetable("4.B Sk1")
print(f"Class 4.B Sk1 has {len(timetable.timetable)} scheduled entries")
# Close the client when done
client.close()
Using Context Manager
from bakalapi import BakalapiClient
with BakalapiClient() as client:
timetable = client.get_teacher_timetable("Mgr. Hana Jaitnerová")
# Client is automatically closed when exiting the context
Accessing Data
The library provides structured data models:
from bakalapi import BakalapiClient
client = BakalapiClient()
timetable = client.get_teacher_timetable("Mgr. Hana Jaitnerová")
# Access hour definitions
for hour in timetable.hours:
print(f"Hour {hour.number}: {hour.start_time} - {hour.end_time}")
# Access timetable entries
for entry in timetable.timetable:
print(f"Day: {entry.day}")
print(f"Date: {entry.date}")
print(f"Time: {entry.time}")
print(f"Subject: {entry.subject}")
print(f"Teacher: {entry.teacher}")
print(f"Room: {entry.room}")
print(f"Class: {entry.class_name}")
print(f"Theme: {entry.theme}")
print(f"Change info: {entry.changeinfo}")
print("---")
Error Handling
from bakalapi import BakalapiClient, BakalapiAPIError
client = BakalapiClient()
try:
timetable = client.get_teacher_timetable("Non-existent Teacher")
except BakalapiAPIError as e:
print(f"API Error: {e}")
print(f"Status Code: {e.status_code}")
except ValueError as e:
print(f"Invalid parameter: {e}")
API Methods
get_teacher_timetable(teacher_name: str) -> TimetableResponse
Get the timetable for a specific teacher.
Parameters:
teacher_name: The name of the teacher (e.g., "Mgr. Hana Jaitnerová")
Returns:
TimetableResponse: Object containing hours and timetable entries
get_room_timetable(room_index: str) -> TimetableResponse
Get the timetable for a specific room.
Parameters:
room_index: The room index/identifier (e.g., "a1")
Returns:
TimetableResponse: Object containing hours and timetable entries
get_class_timetable(class_name: str) -> TimetableResponse
Get the timetable for a specific class.
Parameters:
class_name: The name of the class (e.g., "4.B Sk1")
Returns:
TimetableResponse: Object containing hours and timetable entries
Data Models
TimetableResponse
hours: List[Hour]- List of hour definitionstimetable: List[TimetableEntry]- List of timetable entries
Hour
number: int- Hour numberstart_time: str- Start time (e.g., "8:00")end_time: str- End time (e.g., "8:45")
TimetableEntry
day: str- Day abbreviation (e.g., "po", "út", "st")date: str- Date (e.g., "12.1.")hour_number: int- Hour numbertime: str- Time range (e.g., "8:00 - 8:45")subject: str- Subject nameteacher: str- Teacher name(s)room: str- Room identifierclass_name: str- Class name(s)theme: Optional[str]- Lesson theme/topicnotice: Optional[str]- Notice/notechangeinfo: Optional[str]- Change informationentry_type: str- Entry type (e.g., "atom")
Notes
- Parameters cannot be combined: You can only query by one type (teacher, room, or class) at a time.
- The API endpoint is:
https://bakalapi-production.up.railway.app/api/timetable/ - All parameters are automatically URL-encoded for safe transmission.
Publishing to PyPI
If you want to publish this package to PyPI so others can install it with pip install bakalapi:
-
Install build tools:
pip install build twine
-
Build the package:
python -m build
-
Upload to PyPI (test first with TestPyPI):
# Test upload twine upload --repository testpypi dist/* # Production upload twine upload dist/*
Note: Update the pyproject.toml file with your actual author information and repository URLs before publishing.
License
This library is provided as-is for accessing the Bakalapi timetable API.
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 bakalapi-1.0.0.tar.gz.
File metadata
- Download URL: bakalapi-1.0.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32131c4624252e9fa112d7a89e7eca28d7d2cd47c6d722af3a70f2ea4213af3a
|
|
| MD5 |
ce929c999392fbb65847d74a15d88fff
|
|
| BLAKE2b-256 |
43af85f637796d35a57029016e3feaa83fe7e1d5e56fa070fbaa6f18ee3e6115
|
File details
Details for the file bakalapi-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bakalapi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3df397e73996e17435008f5961101a3605458cac888f798ffc4724fafae7fc53
|
|
| MD5 |
4943b9d7823fc9a14030c612902ebed3
|
|
| BLAKE2b-256 |
7f2a50981e78dd2d0075880bda33416c447de6125016563233da5deb5faac99c
|