Skip to main content

Librus (polish school e-register) unofficial async API client written in Python.

Reason this release was yanked:

unreleased

Project description

PyLibrus

PyPI version Python versions License: MIT

Librus (polish school e-register) unofficial async API client written in Python.

Features

  • Async/await support - Built with httpx for modern async Python
  • 🔐 OAuth authentication with token refresh
  • 📚 Access to all Librus API resources
  • 🧪 Comprehensive test suite
  • 🔄 GitHub Actions CI/CD
  • 📦 Dependabot integration

Installation

pip install pylibrus

Usage

(Replace every field containing 'your' with your data)

Authorization

  • Authorize using existing token (load existing tokens pair)
    or
  • Generate new OAuth token
    • using user credentials:
      import asyncio
      import pylibrus
      
      async def main():
          access_token, refresh_token = await pylibrus.auth.user_credentials(
              username="yourusername",
              password="yourpassword",
              long_lived=True  # optional, if set to True (default) token will be valid for 24h
          )
          print(
              access_token,  # used to access resources
              refresh_token  # used to regenerate access token without user credentials
          )
      
      asyncio.run(main())
      
    • using previously generated refresh token:
      import asyncio
      import pylibrus
      
      async def main():
          access_token, refresh_token = await pylibrus.auth.refresh_token(
              refresh_token="yourrefreshtoken",
              long_lived=True  # default True (if not specified)
          )
          print(access_token, refresh_token)
      
      asyncio.run(main())
      

Accessing resources

Access resources using previously generated access token (see Authorization):

import asyncio
import pylibrus

async def main():
    async with pylibrus.Librus("youraccesstoken") as lib:
        json_res = await lib.getResource("YourResourceName")
        print(json_res)  # Raw API response (decoded JSON as dict)

asyncio.run(main())

List of available resources here.

Examples

Get user name using login/password authorization:

import asyncio
import pylibrus

async def main():
    access_token, _ = await pylibrus.auth.user_credentials(
        username="yourusername",
        password="yourpassword",
    )
    async with pylibrus.Librus(access_token) as lib:
        names = (await lib.getResource("Me"))["Me"]["User"]
        print(f"Hello {names['FirstName']} {names['LastName']}")

asyncio.run(main())

Get number of user's grades using new access token generated using previously cached refresh token:

import asyncio
import pylibrus

async def main():
    access_token, _ = await pylibrus.auth.refresh_token(
        refresh_token="yourrefreshtoken"
    )
    async with pylibrus.Librus(access_token) as lib:
        grades = (await lib.getResource("Grades"))["Grades"]
        print(len(grades))

asyncio.run(main())

Development

You can set up a development environment like this:

git clone https://github.com/YOU/YOUR_FORK.git .
python3 -m venv venv
source venv/bin/activate
pip install -e ".[dev]"

Run tests:

pytest

Run linting:

ruff check .
mypy pylibrus

Contribute

We welcome contributions! Here's how to get started:

Making Changes

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting:
    pytest
    ruff check .
    mypy pylibrus
    
  5. Commit your changes with descriptive messages
  6. Push to your fork and open a Pull Request
  7. Add appropriate labels to your PR:
    • feature - New features or enhancements
    • bug - Bug fixes
    • documentation - Documentation updates
    • chore - Maintenance tasks
    • breaking - Breaking changes

Release Process

This project uses automated releases via GitHub Actions:

  1. Update version in setup.py
  2. Update CHANGELOG.md (or it will be auto-generated from PRs)
  3. Commit changes:
    git add setup.py CHANGELOG.md
    git commit -m "Bump version to X.Y.Z"
    
  4. Create and push tag:
    git tag vX.Y.Z
    git push origin main --tags
    
  5. Automated workflow will:
    • Run tests and linting
    • Build the package
    • Publish to PyPI
    • Create GitHub release with changelog

For more details, see docs/RELEASE.md.

Questions or Issues?

Feel free to open an issue on GitHub!

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

pylibrus-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

pylibrus-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file pylibrus-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for pylibrus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f5e7c9a4a5f41d4ca02474979b9bd94ceb09265e5ee87120e31291aa0612c56c
MD5 79dd4bf2aad25e003669a96218cc6825
BLAKE2b-256 6bbf59efb810ce04bbfb1dd7b85057c335bee134baf98b1019841938ab9e82ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylibrus-0.1.0.tar.gz:

Publisher: release.yml on chmielowiec/pylibrus

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

File details

Details for the file pylibrus-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pylibrus-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 750933605b5ba5dc5ac3e4a3b6d7ab34a0c18ba54a3e324f39e210f71b5cf3b4
MD5 dd9233cf379da8431382eb9fda601ff4
BLAKE2b-256 52db9c71cd458a9b18ab6589a2c4750cc7a12ea5887dd01bfd47b61f4b304641

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylibrus-0.1.0-py3-none-any.whl:

Publisher: release.yml on chmielowiec/pylibrus

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