Repository navigation
Meals and Restrictions
Two enums describe what a meal is and what you may do with it.
What kind of item this is.
| value | meaning |
|---|---|
MealType.SOUP |
Soup |
MealType.MAIN |
Main dish |
MealType.UNKNOWN |
Anything else the canteen serves |
from strava_cz import MealType
soups = strava.menu.get_meals(meal_types=[MealType.SOUP])
lunches = strava.menu.get_meals(meal_types=[MealType.MAIN])The type comes from the API's short druh code — "PO" for soup, "O1", "O2", … for
main dishes — which stays the same whatever display language you request. The
human-readable druh_popis is only a fallback.
Unknown types are kept, not dropped. A canteen serving breakfast or dinner produces
meals the library cannot classify; they come back as UNKNOWN with everything else
intact, rather than disappearing from the menu. meal.variant still carries the
canteen's own label:
for meal in strava.menu.get_meals(meal_types=[MealType.UNKNOWN]):
print(meal.variant, meal.name) # e.g. "Večeře", "Svíčková"If your canteen serves something the library should recognise properly, please
open an issue with the druh
code from meal.raw.
Why the canteen will not let you order or change a meal.
| value | meaning |
|---|---|
Restriction.NONE |
No restriction — go ahead |
Restriction.CLOSED |
The ordering deadline for that day has passed |
Restriction.UNAVAILABLE |
The item cannot be ordered separately (typically soup) |
Restriction.NO_SCHOOL |
The canteen does not cook that day |
Restriction.UNKNOWN |
The canteen sent a code this library does not know |
Every restriction has a .description for messages and an .allowed flag:
meal.order_restriction.description # "the ordering deadline for this day has passed"
meal.order_restriction.allowed # FalseTwo booleans answer the question directly:
meal.can_order # may this be ordered now
meal.can_cancel # may an existing order be cancelled nowThey correspond to order_restriction and cancel_restriction, which explain a False.
The usual pattern:
for meal in strava.menu.get_meals():
if meal.ordered:
print(f"{meal.name}: ordered")
elif meal.can_order:
print(f"{meal.name}: available")
else:
print(f"{meal.name}: {meal.order_restriction.description}")Or let the library filter for you:
available = strava.menu.get_meals(orderable=True)
blocked = strava.menu.get_meals(orderable=False)The canteen reports restrictions per meal in the API's omezeniObj object:
| field | scope | meaning |
|---|---|---|
obj |
one meal | may it be ordered → can_order
|
zm |
one meal | may an order be changed → can_cancel
|
bur |
one meal | is it on the canteen's exchange (not modelled yet) |
den |
the whole day | a day-level code → Day.status
|
An empty string in obj or zm means "allowed"; any other value is a single letter
naming the reason — "C" deadline passed, "I" never separately orderable, "V" no
cooking. Unrecognised letters become Restriction.UNKNOWN instead of raising, so a
change at the canteen's end cannot break your script.
The raw values are always available:
print(meal.raw["omezeniObj"]) # {'den': '', 'obj': '', 'zm': '', 'bur': 'C'}
print(day.day_code) # '' or 'VP' or 'T'
print(day.status) # DayStatus.NORMALWhy this matters. Versions up to 0.2.0 read only the day-level
denfield and ignoredobjandzm. That misjudged which meals were orderable: days carrying the code"T"were treated as unorderable and vanished from the default listing, and on menus wheredenwas set on every meal the library returned an empty menu. If you are upgrading and your menu suddenly has more days in it, that is why. See API Internals for the full picture.
den has its own enum, DayStatus, because it says something about the day rather than
about a meal:
| value | meaning |
|---|---|
NORMAL |
an ordinary day |
NOT_AUTO_ORDERED |
the canteen's standing order skips this day |
NO_SCHOOL |
the canteen does not cook |
CLOSED |
the day's deadline has passed |
UNKNOWN |
a code this library does not recognise |
NOT_AUTO_ORDERED (den: "T") is the one worth knowing about. It does not restrict
anything — those meals have obj: "" and can_order is True. It means the canteen
will not order that day on your behalf, so unless you order it yourself, nothing
arrives. Typically it is the weekday the school does not teach.
day = strava.menu.get_by_date("2026-09-04")
day.auto_ordered # False - nothing will appear here on its own
day.orderable # ...but these meals can still be ordered
# What an automatic ordering tool should look at
strava.menu.get_meals(auto_ordered=True, orderable=True)
# The days a human has to decide about
strava.menu.get_days(auto_ordered=False)Nothing is hidden by default: these are ordinary orderable days.
In most canteens soup comes with the main dish and cannot be ordered on its own; the API
marks it obj: "I", which the library reports as Restriction.UNAVAILABLE.
That is a fact about the canteen, not a rule in the library. Where a canteen does let you order soup separately it says so, and ordering it works:
soup = strava.menu.get_meals(meal_types=[MealType.SOUP])[0]
if soup.can_order:
strava.menu.order_meals(soup.id)A named tuple of (code, name):
for allergen in meal.allergens:
print(allergen.code, allergen.name) # "01", "Obiloviny obsahující lepek"
print(", ".join(str(a) for a in meal.allergens))
# Avoid something
risky = [m for m in strava.menu.get_meals() if any(a.code == "07" for a in m.allergens)]Allergens are declared by the canteen and are sometimes missing on a meal that has them. Do not rely on this field for a serious allergy.