Python wrapper for the Knuspr.de grocery delivery API
Project description
knuspr-api
Unofficial Python wrapper for the Knuspr.de grocery delivery API. Search products, manage your cart, check delivery slots, and view orders — from Python or the command line.
Note: Knuspr is the German brand of the Rohlik Group, which also operates Rohlik.cz, Gurkerl.at, Kifli.hu, and Sezamo.ro. This library targets the German Knuspr.de endpoint.
Features
- Product search with automatic promoted-item filtering
- Cart management — add items, view cart, remove by order field ID
- Delivery slots — check available time windows
- Order history — list past orders and view details
- Upcoming orders — see scheduled deliveries
- Premium info — check subscription status
- Account data — aggregated view of your account
- CLI with 8 commands and rich terminal output
- Cookie-based auth with automatic login/logout via context manager
- Rate limiting — configurable minimum interval between requests (default 100ms)
- Pydantic v2 models with full type annotations (PEP 561)
Installation
From PyPI:
pip install knuspr-api
With uv:
uv add knuspr-api
From source:
git clone https://github.com/kegelmeier/knuspr-api.git
cd knuspr-api
uv pip install -e ".[dev]"
Quick Start
Set your Knuspr.de credentials:
export KNUSPR_USERNAME="your_email@example.com"
export KNUSPR_PASSWORD="your_password"
Or create a .env file (see .env.example).
from knuspr import KnusprClient
with KnusprClient() as client:
# Search for products
products = client.search_products("Bio Vollmilch", limit=5)
for p in products:
print(f"{p.name} - {p.price_value:.2f} EUR")
# Add the first result to your cart
client.add_to_cart(products[0].id, quantity=2)
# Check your cart
cart = client.get_cart()
print(f"Cart: {cart.total_price:.2f} EUR ({cart.total_items} items)")
Configuration
All settings can be provided via environment variables (prefix KNUSPR_) or a .env file:
| Variable | Default | Description |
|---|---|---|
KNUSPR_USERNAME |
(required) | Your Knuspr.de email |
KNUSPR_PASSWORD |
(required) | Your Knuspr.de password |
KNUSPR_BASE_URL |
https://www.knuspr.de |
API base URL |
KNUSPR_MIN_REQUEST_INTERVAL |
0.1 |
Minimum seconds between requests |
KNUSPR_REQUEST_TIMEOUT |
10.0 |
HTTP request timeout in seconds |
KNUSPR_DEBUG |
false |
Enable debug mode |
You can also pass credentials directly:
with KnusprClient(username="me@example.com", password="secret") as client:
...
CLI Reference
The knuspr command provides 8 subcommands with rich terminal output:
# Search products
knuspr search "Hafermilch" --limit 5
# Add a product to your cart (by product ID)
knuspr add 12345 --quantity 3
# View your cart
knuspr cart
# Remove an item from your cart (by order field ID from cart output)
knuspr remove <order_field_id>
# Check delivery time slots
knuspr slots
# View order history
knuspr orders --limit 10
# View a specific order's details
knuspr order <order_id>
# View account overview
knuspr account
Python API
KnusprClient
Use as a context manager for automatic login and logout:
with KnusprClient() as client:
...
Methods
| Method | Returns | Description |
|---|---|---|
search_products(query, limit=10) |
list[SearchResult] |
Search for products |
add_to_cart(product_id, quantity=1) |
int |
Add a product to the cart |
get_cart() |
Cart |
Get current cart contents |
remove_from_cart(order_field_id) |
bool |
Remove an item by its order field ID |
get_delivery_slots() |
list[DeliverySlot] |
Get available delivery windows |
get_order_history(limit=50, offset=0) |
list[Order] |
Get past delivered orders |
get_order_detail(order_id) |
Order |
Get details for a specific order |
get_upcoming_orders() |
list[Order] |
Get scheduled upcoming orders |
get_premium_info() |
PremiumProfile |
Get premium subscription info |
get_account_data() |
AccountData |
Get aggregated account overview |
Models
All models use Pydantic v2 with extra="allow" to handle unexpected API fields gracefully.
SearchResult— Product from search:id,name,price_value,brand,amount,in_stock,image_pathCart— Cart state:total_price,total_items,can_make_order,itemsCartItem— Item in cart:order_field_id,product_id,product_name,quantity,price,brandOrder— Order summary:id,status,created_at,total_price,all_productsOrderProduct— Product within an order:product_id,display_name,quantity,priceDeliverySlot— Time window:id,start,end,is_available,pricePremiumProfile— Subscription:is_premium,valid_untilAccountData— Aggregated:user_id,address_id,premium,cart
Exceptions
from knuspr import KnusprError, AuthenticationError, RateLimitError, APIError, NetworkError
| Exception | When |
|---|---|
KnusprError |
Base exception for all errors |
AuthenticationError |
Login failed or session expired |
RateLimitError |
HTTP 429 — too many requests |
APIError |
API returned an error status |
NetworkError |
Connection or timeout failure |
Disclaimer
This is an unofficial library using reverse-engineered API endpoints. It is not affiliated with, endorsed by, or connected to Rohlik Group or Knuspr GmbH in any way.
- The API may change without notice, which could break this library.
- Use at your own risk and for personal use only.
- Please respect Knuspr's terms of service and rate limits.
Contributing
# Install dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Run linter
ruff check src/ tests/
# Run type checker
mypy src/
License
MIT License. See LICENSE for details.
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 knuspr_api-0.3.0.tar.gz.
File metadata
- Download URL: knuspr_api-0.3.0.tar.gz
- Upload date:
- Size: 44.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc74088d6900fc3968185b941ea342fbeb8f4e25a3ec7edee58b4cad6dd21ad7
|
|
| MD5 |
0cbbd7923a342a5d732e984c898c1ff1
|
|
| BLAKE2b-256 |
4fe5b565027835ffe8aed175bede447f0a8a808d15bbde26c5ec503f18533900
|
Provenance
The following attestation bundles were made for knuspr_api-0.3.0.tar.gz:
Publisher:
publish.yml on kegelmeier/knuspr-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
knuspr_api-0.3.0.tar.gz -
Subject digest:
fc74088d6900fc3968185b941ea342fbeb8f4e25a3ec7edee58b4cad6dd21ad7 - Sigstore transparency entry: 947349395
- Sigstore integration time:
-
Permalink:
kegelmeier/knuspr-api@4b4b04dabf78e49748b025529b7b5df39d215609 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/kegelmeier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4b4b04dabf78e49748b025529b7b5df39d215609 -
Trigger Event:
push
-
Statement type:
File details
Details for the file knuspr_api-0.3.0-py3-none-any.whl.
File metadata
- Download URL: knuspr_api-0.3.0-py3-none-any.whl
- Upload date:
- Size: 13.9 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 |
6d5e32d25363a7a05ae14915264b12d4eea720e9bc386bf26a1324e6eb791024
|
|
| MD5 |
ab88ae1feb062ca43578e478107a7da0
|
|
| BLAKE2b-256 |
dbda52c071427457a3dc6eddecddbca4e2d4dbc5c14ccf999bbf003de965abfd
|
Provenance
The following attestation bundles were made for knuspr_api-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on kegelmeier/knuspr-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
knuspr_api-0.3.0-py3-none-any.whl -
Subject digest:
6d5e32d25363a7a05ae14915264b12d4eea720e9bc386bf26a1324e6eb791024 - Sigstore transparency entry: 947349399
- Sigstore integration time:
-
Permalink:
kegelmeier/knuspr-api@4b4b04dabf78e49748b025529b7b5df39d215609 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/kegelmeier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4b4b04dabf78e49748b025529b7b5df39d215609 -
Trigger Event:
push
-
Statement type: