Klokku REST API client
Project description
Klokku Python Client
A Python client for interacting with the Klokku REST API.
Installation
Using pip
pip install klokku-python-client
Using Poetry
poetry add klokku-python-client
Usage
The client provides an asynchronous interface to the Klokku API:
import asyncio
from klokku_python_client import KlokkuApi
async def main():
# Create a client instance
async with KlokkuApi("https://app.klokku.com/") as client:
# Authenticate with a username (self‑hosted) or a personal access token (cloud)
# authenticated = await client.authenticate("your_username")
authenticated = await client.authenticate("pat.<the-rest-of-the-token>")
if not authenticated:
print("Authentication failed")
return
# Get weekly plan
weekly_plan = await client.get_current_week_plan()
if not weekly_plan:
print("Failed to fetch weekly plan")
return
if weekly_plan.items:
print(f"Found {len(weekly_plan.items)} budgets:")
for item in weekly_plan.items:
print(f"- {item.name} (ID: {item.budgetItemId})")
# Get current event
current_event = await client.get_current_event()
if current_event:
print(f"Current item: {current_event.planItem.name}")
print(f"Started at: {current_event.startTime}")
# Set a different item
if weekly_plan.items and len(weekly_plan.items) > 1:
new_budget_id = weekly_plan.items[1].budgetItemId
result = await client.set_current_event(new_budget_id)
if result:
print(f"Set current item to ID: {new_budget_id}")
# Run the async function
asyncio.run(main())
Features
- Asynchronous API client using
aiohttp - Authentication with username
- Get list of users
- Get all budgets
- Get current event/budget
- Set current budget
- Context manager support for proper resource cleanup
Development
CI/CD
This project uses GitHub Actions for continuous integration and deployment:
- Build Workflow: Runs on every push to the main branch, executing tests and building the package.
- Publish Workflow: Automatically publishes the package to PyPI when a new GitHub Release is created.
To set up the publishing workflow:
- Generate a PyPI API token at https://pypi.org/manage/account/token/
- Add the token as a GitHub repository secret named
PYPI_API_TOKEN - Create a new GitHub Release to trigger the publishing workflow
Setup
- Clone the repository
- Install dependencies with Poetry:
poetry install
Testing
The project uses pytest for testing with aioresponses for mocking HTTP requests.
To install test dependencies:
pip install -e ".[test]"
Or with Poetry:
poetry install --with test
To run the tests:
pytest
Or with Poetry
poetry run pytest
For more details about testing, see the tests README.
Releasing
- Upgrade the version in
pyproject.toml - Create a new GitHub Release
- The GitHub Actions build workflow will automatically publish the package to PyPI
Requirements
- Python 3.13+
- aiohttp 3.12+
License
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
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 klokku_python_client-0.5.0.tar.gz.
File metadata
- Download URL: klokku_python_client-0.5.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.11 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ab09cacd3e8ef4d7b2318470c3e1cb3b0af3294e996f5f78c19d6a4f2f88f69
|
|
| MD5 |
5a93fb2577ca1cbfa32a6325230bf44e
|
|
| BLAKE2b-256 |
6f7fed843a9a91991f9e4b4b697f635471ede0e7eb73ccf2467c64a54362de47
|
File details
Details for the file klokku_python_client-0.5.0-py3-none-any.whl.
File metadata
- Download URL: klokku_python_client-0.5.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.11 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff190b0467cde5a4c60f3d2e8f54d5650a80079c91411b2b3809b142ec27a204
|
|
| MD5 |
97cd54f083d8e8b21b7e4b18f27558ec
|
|
| BLAKE2b-256 |
62ea0721110433dce508150b90aad4842b5ddc6dc0c89627bdeb80e4007d6813
|