Skip to main content

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://api.klokku.example.com/") as client:
        # Authenticate with a username
        authenticated = await client.authenticate("your_username")
        if not authenticated:
            print("Authentication failed")
            return

        # Get all budgets
        budgets = await client.get_all_budgets()
        if budgets:
            print(f"Found {len(budgets)} budgets:")
            for budget in budgets:
                print(f"- {budget.name} (ID: {budget.id})")

        # Get current event
        current_event = await client.get_current_event()
        if current_event:
            print(f"Current budget: {current_event.budget.name}")
            print(f"Started at: {current_event.startTime}")

        # Set a different budget
        if budgets and len(budgets) > 1:
            new_budget_id = budgets[1].id
            result = await client.set_current_budget(new_budget_id)
            if result:
                print(f"Set current budget 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

Setup

  1. Clone the repository
  2. 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

For more details about testing, see the tests README.

Requirements

  • Python 3.13+
  • aiohttp 3.11+

License

MIT

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

klokku_python_client-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

klokku_python_client-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: klokku_python_client-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.9.21 Darwin/24.3.0

File hashes

Hashes for klokku_python_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e9b9aabe09c028a8c0e3c0183bd9109ceaf8c553225515c702aa8ccc30fa536a
MD5 00eb95d6b9295079fcdb2b5e816ce126
BLAKE2b-256 dd8c340703386893fd4fedcd48058c1f77ef76383e0a899e38e7f267f9ff40ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for klokku_python_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 871893ba9cd02f3252fa9d4f49120e80a1912d60466ff831d0feb730dba13e7b
MD5 fcbed19355dc7c27b12b2007e5cc5f04
BLAKE2b-256 9bdd6521d9dae0b8ce091a56016e384a97a8e3dcead053c65b052504d5a894c8

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