A Python wrapper for accessing and processing Kinexon Handball data.
Project description
Kinexon Handball API
A Python wrapper for the Kinexon Handball API.
This library simplifies interaction with the Kinexon API by handling complex two-step authentication automatically and providing a fully typed interface for all API endpoints.
Features
- Automated Authentication: Handles the multi-step login process (Session + Main) and API key injection automatically.
- Fully Typed: Built on top of a generated OpenAPI client, ensuring type safety for requests and response models.
- High-Level Helpers: Convenient methods for common workflows (e.g., fetching metrics, team rosters, and position data).
- Hybrid Architecture:
- Use high-level helpers in
kinexon_handball_apifor ease of use. - Access the underlying
kinexon_clientfor raw access to every single API endpoint generated from the official spec.
- Use high-level helpers in
Installation
This project requires Python 3.13+.
Using uv (Recommended)
If you use uv for fast package management:
git clone https://github.com/mad4ms/KinexonHandballAPI.git
cd KinexonHandballAPI
uv sync
If you prefer an editable install instead of syncing a lockfile:
uv pip install -e "."
Configuration
The library uses python-dotenv to manage configuration. You can provide credentials via a .env file in your project root or via environment variables.
Create a .env file:
# API Authorization
API_KEY_KINEXON=your_api_key
# Step 1: Session Authentication
USERNAME_KINEXON_SESSION=your_session_username
PASSWORD_KINEXON_SESSION=your_session_password
ENDPOINT_KINEXON_SESSION=https://hbl-cloud.kinexon.com/
# Step 2: Main Authentication
USERNAME_KINEXON_MAIN=your_main_username
PASSWORD_KINEXON_MAIN=your_main_password
ENDPOINT_KINEXON_MAIN=https://hbl-cloud.kinexon.com/checklogin
# API Base Configuration (no trailing /public/v1)
ENDPOINT_KINEXON_API=https://hbl-cloud.kinexon.com
Note: The two-step authentication requires separate credentials for each step.
Usage
Basic Example
The main entry point is the HandballAPI class.
import os
from dotenv import load_dotenv
from kinexon_handball_api.handball import HandballAPI
from kinexon_handball_api.fetchers import fetch_team_ids
# 1. Load configuration
load_dotenv()
# 2. Initialize the API
api = HandballAPI(
base_url=os.getenv("ENDPOINT_KINEXON_API", ""),
api_key=os.getenv("API_KEY_KINEXON", ""),
username_basic=os.getenv("USERNAME_KINEXON_SESSION", ""),
password_basic=os.getenv("PASSWORD_KINEXON_SESSION", ""),
username_main=os.getenv("USERNAME_KINEXON_MAIN", ""),
password_main=os.getenv("PASSWORD_KINEXON_MAIN", ""),
endpoint_session=os.getenv("ENDPOINT_KINEXON_SESSION", ""),
endpoint_main=os.getenv("ENDPOINT_KINEXON_MAIN", ""),
)
# 3. Use high-level helpers
# Fetch available metrics
metrics = api.get_available_metrics_and_events()
print(f"Found {len(metrics)} available metrics.")
# Get players for a specific team
teams = fetch_team_ids()
if teams:
first_team = teams[0]
players = api.get_team_players(team_id=first_team["id"])
print(f"Team {first_team['name']} has {len(players)} players.")
Advanced: Accessing Raw Client
For endpoints not covered by high-level helpers, accessing the generated client directly is supported and encouraged. The generated client resides in kinexon_client.
from kinexon_client.api.players import get_public_v1_teams_by_team_id_players
from kinexon_client.models import PlayerModel
# You can access the authenticated low-level client via `api.client`
response = get_public_v1_teams_by_team_id_players.sync_detailed(
client=api.client,
team_id=12345
)
if response.status_code == 200:
# Full type support for the response model
data: list[PlayerModel] = response.parsed
print(data[0].firstname)
Advanced: Adding new teams
You can add new teams by modifying config/teams.yaml. Somehow there is no API endpoint to fetch all teams, so this is a manual step for now.
Architecture
This project uses a Wrapper Pattern around a generated OpenAPI client.
src/kinexon_handball_api/: The public-facing code. Contains theHandballAPIclass, authentication logic, and user-friendly helpers.src/_vendor/kinexon_client/: The low-level client code generated from the Kinexon OpenAPI specification.- Note: This directory allows us to ship the generated code without external dependencies or versioning conflicts.
- Do not edit files in
_vendormanually. They are overwritten during code generation.
Repository Layout
src/kinexon_handball_api/: Hand-written wrapper and helper APIs.src/_vendor/kinexon_client/: Generated OpenAPI client (do not edit by hand).scripts/: Code generation helpers for the OpenAPI client.test/: Test suite executed withpytest.
AI Assistance
If you are using GitHub Copilot in this repo, see the project-specific guidance in
.github/copilot-instructions.md.
Development
Setup
# Install dependencies including dev tools
uv pip install -e ".[dev]"
Running Tests
pytest
Note: The integration tests use live API calls and will be skipped if required
environment variables are not set.
Code Generation
If the Kinexon OpenAPI specification changes, you can regenerate the client:
Windows (PowerShell):
./scripts/codegen.ps1
Linux / Mac:
./scripts/codegen.sh
License
Distributed under the MIT License. See LICENSE for more information.
Contributing
Contributions are welcome! Please open issues or pull requests 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 kinexon_handball_api-0.1.1.tar.gz.
File metadata
- Download URL: kinexon_handball_api-0.1.1.tar.gz
- Upload date:
- Size: 87.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
717ce61ff3100a316bf3b2100c1c603d1ed8acb577da7c6df0afd19935e1083f
|
|
| MD5 |
6cf683f4f02c311019997c022730f74a
|
|
| BLAKE2b-256 |
4c320a274ce41cdbe77d9eed9b5367de7b9cedeb4b98d5315a492982cd1bc2f8
|
Provenance
The following attestation bundles were made for kinexon_handball_api-0.1.1.tar.gz:
Publisher:
release.yml on mad4ms/KinexonHandballAPI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kinexon_handball_api-0.1.1.tar.gz -
Subject digest:
717ce61ff3100a316bf3b2100c1c603d1ed8acb577da7c6df0afd19935e1083f - Sigstore transparency entry: 1056025579
- Sigstore integration time:
-
Permalink:
mad4ms/KinexonHandballAPI@ddf563bf0ad93c53ea561eb3803ce4cb528000db -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mad4ms
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ddf563bf0ad93c53ea561eb3803ce4cb528000db -
Trigger Event:
push
-
Statement type:
File details
Details for the file kinexon_handball_api-0.1.1-py3-none-any.whl.
File metadata
- Download URL: kinexon_handball_api-0.1.1-py3-none-any.whl
- Upload date:
- Size: 416.8 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 |
8495a41765560b40715d517d4deff2b573df7bd7397ffda30b362a2c1f63b7b1
|
|
| MD5 |
bb6a53def4d59fb36e4f83daae0b068c
|
|
| BLAKE2b-256 |
408523a43fdf9a2e6f4ff8fbeef930466219114e73cef35aeb1f216fa8396011
|
Provenance
The following attestation bundles were made for kinexon_handball_api-0.1.1-py3-none-any.whl:
Publisher:
release.yml on mad4ms/KinexonHandballAPI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kinexon_handball_api-0.1.1-py3-none-any.whl -
Subject digest:
8495a41765560b40715d517d4deff2b573df7bd7397ffda30b362a2c1f63b7b1 - Sigstore transparency entry: 1056025641
- Sigstore integration time:
-
Permalink:
mad4ms/KinexonHandballAPI@ddf563bf0ad93c53ea561eb3803ce4cb528000db -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mad4ms
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ddf563bf0ad93c53ea561eb3803ce4cb528000db -
Trigger Event:
push
-
Statement type: