Repository navigation
Quick Start
Everything you need to order lunch from Python.
from strava_cz import StravaCZ
strava = StravaCZ("your.username", "YourPassword123", "3753")
print(strava.user)Vojtěch Nerad (your.username)
Email: you@example.com
Balance: 512.50 Kč
Canteen: Školní jídelna, Praha 5 - Smíchov
Better still, use it as a context manager — it logs out and closes the connection pool for you, even if something raises:
with StravaCZ("your.username", "YourPassword123", "3753") as strava:
...Better again, keep the credentials out of the source entirely. Store them once —
strava-cz profile add skola --username your.username --canteen 3753 — and then:
with StravaCZ.from_profile("skola") as strava:
...The password goes to the operating system's keyring, not into any file this library writes. See Profiles.
Nothing is loaded until you ask for it:
strava.menu.fetch()
strava.menu.print()Thu 03.09.2026
[-] 86 Polévka Bramborová (0 Kč) - this item cannot be ordered separately
[ ] 5 Oběd 1 Kuřecí kostky na paprice, těstoviny, čaj (50 Kč)
[ ] 6 Oběd 2 Zapečené těstoviny se šunkou, salát (50 Kč)
The marks are [x] ordered, [ ] orderable, [-] blocked — with the reason spelled out.
from strava_cz import MealType
# Everything, grouped by day or flat
days = strava.menu.get_days()
meals = strava.menu.get_meals()
# Only what you can actually order right now
orderable = strava.menu.get_meals(orderable=True)
# Only main dishes, only this week
lunches = strava.menu.get_meals(
meal_types=[MealType.MAIN],
orderable=True,
date_from="2026-09-07",
date_to="2026-09-11",
)
for meal in lunches:
print(f"{meal.date} [{meal.id}] {meal.name} {meal.price} Kč")Menu behaves like a sequence of days:
print(len(strava.menu)) # number of days with meals
print(strava.menu[0].date) # first day
for day in strava.menu:
print(day.date, len(day.meals))result = strava.menu.order_meals(5, 9)
print(result) # "2 changed"
print(result.changed) # (5, 9)The library stages both meals, saves once, then re-fetches the menu to confirm them. If staging fails, the staged changes are discarded and nothing is saved. A timeout during the save itself is different, and Ordering Meals says what you get then.
strava.menu.cancel_meals(5, 9)from strava_cz import InsufficientBalanceError, MealNotOrderableError
try:
strava.menu.order_meals(5)
except MealNotOrderableError as exc:
print(f"Cannot order this: {exc.reason.description}")
except InsufficientBalanceError:
print(f"Only {strava.user.balance} Kč left")import os
from strava_cz import MealType, StravaCZ
with StravaCZ(
os.environ["STRAVA_USERNAME"],
os.environ["STRAVA_PASSWORD"],
os.environ["STRAVA_CANTEEN"],
) as strava:
strava.menu.fetch()
# Order the first available "Oběd 1" on every day that has nothing ordered yet
for day in strava.menu.get_days():
if day.ordered:
continue
choice = next(
(m for m in day.orderable if m.type is MealType.MAIN and m.variant == "Oběd 1"),
None,
)
if choice:
strava.menu.order_meals(choice.id)
print(f"Ordered {choice.name} for {choice.date}")- Menu System — everything the menu can tell you
- Ordering Meals — transactions, duplicates, partial failures
- Error Handling — the full exception hierarchy
- MCP Server — the same, for an AI agent
A note on meal ids. A meal's
idis the API'svetafield and only holds until the canteen renumbers the menu, at every login and session reset, so the same number can be another meal afterwards. For anything that outlives one fetch, keepmeal.keyinstead, the day and the slot ("2026-09-21:O1").order_meals()andcancel_meals()take either.
Everything above is also a command. See Command Line. And it is an MCP server too,
so an AI agent can order for you: pip install "strava-cz[cli,mcp]", then see
MCP Server.
strava-cz menu --week --orderable
strava-cz order 2026-09-21:O1 --dry-run
strava-cz order 2026-09-21:O1
strava-cz --json ordered | jq '.total_price'