This release is a pre-release and may not be stable for production use.
Pyoekoboxonline
A Python client library for the Ökobox Online e-commerce REST API. This library provides an easy-to-use, async interface for interacting with organic food delivery and subscription services.
Note: This library is designed to be compatible with Home Assistant custom integrations and uses
aiohttpfor HTTP requests.
Requirements
- Python 3.11+ - Modern Python features and performance improvements
- Async/await support - Built with modern Python async patterns
- aiohttp - Modern async HTTP client library
Features
- Type hints - Full type annotation support with mypy
- Pydantic models - Robust data validation and serialization
- Comprehensive error handling - Detailed exception hierarchy
- Well tested - High test coverage with pytest
- Production ready - Follows Python packaging best practices
- External session support - Compatible with Home Assistant's shared aiohttp session
Installation
pip install pyoekoboxonline
Note: Requires Python 3.11 or higher.
Quick Start
Standard Usage
import asyncio
from pyoekoboxonline import OekoboxClient
async def main():
# First, discover available shops
shops = await OekoboxClient.get_shop_info()
print(f"Found {len(shops)} shops")
# Connect to a specific shop
async with OekoboxClient(
shop_id="your_shop_id", # From shop list
username="your-username",
password="your-password"
) as client:
# Login
await client.logon()
# Browse product categories
groups = await client.get_groups()
for group in groups:
print(f"Category: {group.name}")
# Browse products
items = await client.get_items()
for item in items:
print(f"{item.name}: {item.price}")
# Add items to cart
await client.add_to_cart(item_id=123, amount=2.0)
# View orders
orders = await client.get_orders()
for order in orders:
print(f"Order {order.id}")
# Logout
await client.logout()
asyncio.run(main())
Home Assistant Integration (External Session)
For Home Assistant integrations, you can pass an external aiohttp.ClientSession:
import aiohttp
from pyoekoboxonline import OekoboxClient
async def setup_platform(hash, config, async_add_entities, discovery_info=None):
"""Set up the Ökobox Online integration."""
# Use Home Assistant's shared session
session = hash.helpers.aiohttp_client.async_get_clientsession()
# Create client with external session
client = OekoboxClient(
shop_id=config["shop_id"],
username=config["username"],
password=config["password"],
session=session, # Pass the external session
)
# No need for context manager when using external session
await client.logon()
# Use the client...
# The session will be managed by Home Assistant
API Reference
Client
OekoboxClient(shop_id, username, password, base_url=None, timeout=30.0, session=None)
The main client class for interacting with the Ökobox Online API.
Parameters:
shop_id(str): Shop identifier from the shop listusername(str): Your account usernamepassword(str): Your account passwordbase_url(str, optional): Custom base URL (auto-detected from shop_id)timeout(float, optional): Request timeout in seconds (default: 30.0)session(aiohttp.ClientSession, optional): External aiohttp session (for Home Assistant integrations)
Shop Discovery
await OekoboxClient.get_available_shops() -> List[Shop]
Get list of available Ökobox Online shops with location data.
Authentication
await client.login() -> UserInfo
Authenticate and establish session.
await client.logout()
Clear session and logout.
Product Catalog
await client.get_groups() -> List[Group]
Get product categories.
await client.get_items(group_id=None, subgroup_id=None) -> List[Item]
Get available products, optionally filtered by category.
await client.search_items(query: str) -> List[Item]
Search for products by name or description.
Shopping Cart
await client.get_cart() -> List[CartItem]
Get current cart contents.
await client.add_to_cart(item_id: str, quantity: float)
Add item to cart.
await client.clear_cart()
Clear all items from cart.
Orders
await client.get_orders() -> List[Order]
Get customer's orders.
await client.create_order() -> Order
Create order from current cart.
Error Handling
from pyoekoboxonline.exceptions import (
OekoboxAuthenticationError,
OekoboxConnectionError,
OekoboxAPIError
)
try:
user = await client.login()
except OekoboxAuthenticationError:
print("Invalid credentials")
except OekoboxConnectionError as e:
print(f"Connection error: {e}")
except OekoboxAPIError as e:
print(f"API error: {e.message} (status: {e.status_code})")
Development
Setup
# Clone the repository
git clone https://github.com/usimd/pyoekoboxonline.git
cd pyoekoboxonline
# Install with uv (recommended) - requires Python 3.11+
uv sync --dev
# Or with pip
pip install -e ".[dev]"
Testing
# Run tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=src --cov-report=html
Code Quality
# Run all pre-commit hooks (includes ruff, mypy, bandit, etc.)
uv run pre-commit run --all-files
# Install pre-commit hooks for automatic checking
uv run pre-commit install
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Metadata
Release files for pyoekoboxonline 0.1.0b5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyoekoboxonline-0.1.0b5.tar.gz | 30.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyoekoboxonline-0.1.0b5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 63.2 kB
Release files / pyoekoboxonline-0.1.0b5.tar.gz
| Download URL | pyoekoboxonline-0.1.0b5.tar.gz |
|---|---|
| Size | 30.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3f8e95a730f30ca2a7cce64259f91f4c03ded813f8b1769b219a64bff4433c3
|
|
BLAKE2b-256 checksum How to use checksums |
60657b263a3bb7ef73e9d1b8bea4cbb6d185c82eb8237a7d6a4fe864ad70a94b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.7
|
Release files / pyoekoboxonline-0.1.0b5-py3-none-any.whl
| Download URL | pyoekoboxonline-0.1.0b5-py3-none-any.whl |
|---|---|
| Size | 32.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
56b017519d9dad35ff3ec2366b4c183a4f4d6c2add38f8a6832e5a42a4c8556a
|
|
BLAKE2b-256 checksum How to use checksums |
d6c0b15d2fe90836e61a0b9ab7769371ad1e0235d3c8c549828a210519f152bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.7
|
Security for pyoekoboxonline 0.1.0b5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.