Librus (polish school e-register) unofficial async API client written in Python.
Reason this release was yanked:
unreleased
Project description
PyLibrus
Librus (polish school e-register) unofficial async API client written in Python.
Features
- ✨ Async/await support - Built with
httpxfor 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())
- using user credentials:
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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting:
pytest ruff check . mypy pylibrus
- Commit your changes with descriptive messages
- Push to your fork and open a Pull Request
- Add appropriate labels to your PR:
feature- New features or enhancementsbug- Bug fixesdocumentation- Documentation updateschore- Maintenance tasksbreaking- Breaking changes
Release Process
This project uses automated releases via GitHub Actions:
- Update version in
setup.py - Update CHANGELOG.md (or it will be auto-generated from PRs)
- Commit changes:
git add setup.py CHANGELOG.md git commit -m "Bump version to X.Y.Z"
- Create and push tag:
git tag vX.Y.Z git push origin main --tags
- 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5e7c9a4a5f41d4ca02474979b9bd94ceb09265e5ee87120e31291aa0612c56c
|
|
| MD5 |
79dd4bf2aad25e003669a96218cc6825
|
|
| BLAKE2b-256 |
6bbf59efb810ce04bbfb1dd7b85057c335bee134baf98b1019841938ab9e82ba
|
Provenance
The following attestation bundles were made for pylibrus-0.1.0.tar.gz:
Publisher:
release.yml on chmielowiec/pylibrus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylibrus-0.1.0.tar.gz -
Subject digest:
f5e7c9a4a5f41d4ca02474979b9bd94ceb09265e5ee87120e31291aa0612c56c - Sigstore transparency entry: 869016716
- Sigstore integration time:
-
Permalink:
chmielowiec/pylibrus@eea8dc25f2ffd474daf11d8d3a8b724a94005b46 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/chmielowiec
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@eea8dc25f2ffd474daf11d8d3a8b724a94005b46 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
750933605b5ba5dc5ac3e4a3b6d7ab34a0c18ba54a3e324f39e210f71b5cf3b4
|
|
| MD5 |
dd9233cf379da8431382eb9fda601ff4
|
|
| BLAKE2b-256 |
52db9c71cd458a9b18ab6589a2c4750cc7a12ea5887dd01bfd47b61f4b304641
|
Provenance
The following attestation bundles were made for pylibrus-0.1.0-py3-none-any.whl:
Publisher:
release.yml on chmielowiec/pylibrus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylibrus-0.1.0-py3-none-any.whl -
Subject digest:
750933605b5ba5dc5ac3e4a3b6d7ab34a0c18ba54a3e324f39e210f71b5cf3b4 - Sigstore transparency entry: 869016718
- Sigstore integration time:
-
Permalink:
chmielowiec/pylibrus@eea8dc25f2ffd474daf11d8d3a8b724a94005b46 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/chmielowiec
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@eea8dc25f2ffd474daf11d8d3a8b724a94005b46 -
Trigger Event:
push
-
Statement type: