Professional client for interacting with the School App API
Project description
School App Client - Refactored
Clean, organized structure for the School App client with proper separation of concerns.
📁 Project Structure
├── http_client.py # Base HTTP client (GET/POST requests, cookie management)
├── auth.py # Authentication & CSRF token handling
├── school_app_client.py # Main API client (combines everything)
└── example_usage.py # Usage example
🎯 Architecture
1. http_client.py - HTTP Layer
- Handles raw HTTP operations (GET/POST)
- Cookie jar and session management
- Common headers configuration
- Error handling for network requests
2. auth.py - Authentication Layer
- Login flow management
- CSRF token extraction and updates
- Session state tracking
- Decoupled from HTTP implementation
3. school_app_client.py - API Layer
- High-level API methods (
get_filieres(),get_modules()) - Orchestrates HTTP client and auth manager
- Business logic for School App endpoints
🚀 Usage
from school_app_client import SchoolAppClient
# Initialize
client = SchoolAppClient()
# Login
client.login("your.email@example.com", "password")
# Fetch data
filieres = client.get_filieres()
modules = client.get_modules(niveau="1A", filiere="API-MPT", semestre="S1")
# If you encounter 403 errors, force CSRF refresh
modules = client.get_modules(
niveau="1A",
filiere="API-MPT",
semestre="S1",
refresh_csrf=True
)
✨ Benefits of This Structure
- Separation of Concerns: Each module has a single responsibility
- Testability: Easy to mock and unit test each layer
- Maintainability: Changes in one layer don't affect others
- Extensibility: Easy to add new endpoints or authentication methods
- Reusability: HTTP client can be used for other projects
🎯 Key Features
- Automatic CSRF Management: CSRF tokens are automatically refreshed from page content
- Session Persistence: Cookie-based session management keeps you logged in
- Smart Error Handling: Detects 403 errors and suggests CSRF refresh
- Optional CSRF Force Refresh: Use
refresh_csrf=Trueto force token refresh before requests - Clean Separation: HTTP, Auth, and API layers are completely decoupled
🔧 Potential Extensions
- Add logging module
- Implement response parsers (HTML → structured data)
- Add caching layer
- Create async version using
aiohttp - Add retry logic with exponential backoff
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
schoolapp_api-2.0.0.tar.gz
(14.4 kB
view details)
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 schoolapp_api-2.0.0.tar.gz.
File metadata
- Download URL: schoolapp_api-2.0.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1b8fc42ec2f7a770bc741942996f85fe6ffaf893a18bead378a6e6db2b9fd4f
|
|
| MD5 |
a206441e3a14adee42959d1c9937d142
|
|
| BLAKE2b-256 |
d299fa8a4ab37c700ac6d2cdcf3eee70ddf609c771eb38ef0413289930608a8b
|
File details
Details for the file schoolapp_api-2.0.0-py3-none-any.whl.
File metadata
- Download URL: schoolapp_api-2.0.0-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70db7ebfafac65056df06b12f84df2fd9eb60398c31e7f7eefcf51b6353795ed
|
|
| MD5 |
408d5056836bbc6bd25416a141fc7029
|
|
| BLAKE2b-256 |
d066234043ebb045cf36a004d765ac414d58fb5410b6c78c24d9b36f6104decb
|