-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
jsem-nerad edited this page Nov 12, 2025
·
1 revision
Get started with strava-cz-python in just a few minutes!
from strava_cz import StravaCZ, MealType, OrderType
# Create client and login
strava = StravaCZ(
username="your.username",
password="YourPassword123",
canteen_number="3753" # Required parameter
)
# Display user information
print(strava.user)
print(f"Balance: {strava.user.balance} {strava.user.currency}")
# Fetch and display menu
strava.menu.fetch()
strava.menu.print()
# Get orderable meals as list
meals = strava.menu.get_meals()
print(f"Available meals: {len(meals)}")
# Order meals by ID
strava.menu.order_meals(3, 6)
# Check if a meal is ordered
if strava.menu.is_ordered(3):
print("Meal 3 is ordered")
# Cancel meal orders
strava.menu.cancel_meals(3)
# Logout
strava.logout()from strava_cz import StravaCZ, MealType, OrderType-
StravaCZ- Main API client -
MealType- Enum for meal types (SOUP, MAIN) -
OrderType- Enum for order types (NORMAL, RESTRICTED, OPTIONAL)
strava = StravaCZ(
username="your.username",
password="YourPassword123",
canteen_number="3753"
)The client automatically logs in when credentials are provided. The canteen_number is required - it identifies your specific school canteen.
print(strava.user.full_name) # Full name
print(strava.user.email) # Email address
print(strava.user.balance) # Account balance
print(strava.user.currency) # Currency (usually "Kč")
print(strava.user.canteen_name) # Canteen namestrava.menu.fetch()This downloads the menu data from the server. You must call this before accessing menu items.
# Print formatted menu
strava.menu.print()
# Get menu information
print(f"Menu: {strava.menu}") # Shows number of days and meals
print(f"Days: {len(strava.menu)}") # Number of orderable days# Get all orderable meals (default)
meals = strava.menu.get_meals()
# Get only main dishes
main_meals = strava.menu.get_meals(meal_types=[MealType.MAIN])
# Get only soups
soups = strava.menu.get_meals(meal_types=[MealType.SOUP])
# Get ordered meals only
ordered = strava.menu.get_meals(ordered=True)
# Get unordered meals only
unordered = strava.menu.get_meals(ordered=False)# Get meals grouped by days
days = strava.menu.get_days()
for day in days:
print(f"Date: {day['date']}")
for meal in day['meals']:
print(f" - {meal['name']} ({meal['price']} Kč)")# Order meals by ID
strava.menu.order_meals(3, 6)
# Cancel meal orders
strava.menu.cancel_meals(3, 6)
# Check if meal is ordered
is_ordered = strava.menu.is_ordered(3)strava.logout()Each meal has a unique ID that changes daily. To find meal IDs:
strava.menu.fetch()
# Print menu with IDs
for day in strava.menu.get_days():
print(f"\n{day['date']}:")
for meal in day['meals']:
print(f" ID: {meal['id']} - {meal['name']}")from strava_cz import (
StravaCZ,
AuthenticationError,
InvalidMealTypeError,
InsufficientBalanceError,
StravaAPIError
)
try:
strava = StravaCZ(
username="your.username",
password="YourPassword123",
canteen_number="3753"
)
strava.menu.fetch()
strava.menu.order_meals(3, 6)
except AuthenticationError as e:
print(f"Login failed: {e}")
except InvalidMealTypeError as e:
print(f"Invalid meal type: {e}")
except InsufficientBalanceError as e:
print(f"Not enough balance: {e}")
except StravaAPIError as e:
print(f"API error: {e}")
finally:
if strava.user.is_logged_in:
strava.logout()from strava_cz import StravaCZ, MealType, OrderType
def main():
# Login
strava = StravaCZ(
username="your.username",
password="YourPassword123",
canteen_number="3753"
)
print(f"Logged in as: {strava.user.full_name}")
print(f"Balance: {strava.user.balance} Kč\n")
# Fetch menu
strava.menu.fetch()
# Get next 3 days with main dishes
days = strava.menu.get_days(meal_types=[MealType.MAIN])[:3]
print("Next 3 days menu:")
meal_ids_to_order = []
for day in days:
print(f"\n{day['date']}:")
for meal in day['meals']:
print(f" [{meal['id']}] {meal['name']} - {meal['price']} Kč")
if not meal['ordered']:
meal_ids_to_order.append(meal['id'])
# Order first meal from each day
if meal_ids_to_order[:3]:
print(f"\nOrdering meals: {meal_ids_to_order[:3]}")
strava.menu.order_meals(*meal_ids_to_order[:3])
print("Meals ordered successfully!")
# Show updated balance
print(f"New balance: {strava.user.balance} Kč")
# Logout
strava.logout()
print("Logged out")
if __name__ == "__main__":
main()- Learn more about Menu System and data structures
- Understand Meal Types and Orders
- Explore Filtering and Queries
- Read about Error Handling best practices