Skip to main content

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=True to 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)

Uploaded Source

Built Distribution

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

schoolapp_api-2.0.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

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

Hashes for schoolapp_api-2.0.0.tar.gz
Algorithm Hash digest
SHA256 d1b8fc42ec2f7a770bc741942996f85fe6ffaf893a18bead378a6e6db2b9fd4f
MD5 a206441e3a14adee42959d1c9937d142
BLAKE2b-256 d299fa8a4ab37c700ac6d2cdcf3eee70ddf609c771eb38ef0413289930608a8b

See more details on using hashes here.

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

Hashes for schoolapp_api-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70db7ebfafac65056df06b12f84df2fd9eb60398c31e7f7eefcf51b6353795ed
MD5 408d5056836bbc6bd25416a141fc7029
BLAKE2b-256 d066234043ebb045cf36a004d765ac414d58fb5410b6c78c24d9b36f6104decb

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