Quickstart

Follow this guide to get up and running in no time.

This guide assumes that you already have Python 3 and pip3 installed. If not, you can download it from the Python website.

Installation

First, install the library by using

pip3 install lunchbot-api 

In case the above doesn't work, try using simply "pip", but make sure that pip will install the library to a Python 3 interpreter. Python 2 is not supported.

Right now, you also have to install the following things via pip (apart from the lunchbot-api package):

  • requests

  • websockets

  • pytz

Importing the library

Import the library like this:

from lunchbot_python import EateryNod

Using the library

The library has two important classes, which are "Menu" and "Day". The Menu class represents the full weekly menu, and it has a list of Day objects, that represents the menu for individual days.

Here is simple code to get and parse the menu:

from eatery_nod import EateryNod #Import the library
menu = EateryNod.Menu() #Create a menu object
menu.initialize() #Initialize (this is only required when using WebSockets)
print("Retrieving menu...") #Print out the status
week_menu = menu.get_menu() #Get the menu

Here is how you can treat the data (assumes that the rows above are present in your code):

The below code example is designed to be clear. You can write the same stuff with less/more compact code.

for day in week_menu: #Loop through all the days in the menu
    menu_items_str = "\n".join(day.menu_items) #Format the menu items to a pretty string as they are returned as a list
    print(day.day_name_sv) #Print out the day name (in Swedish)
    print(menu_items_str) #Print out the menu items
    print("Day information:") #Print out a nice divider
    print("Date: " + str(day.day_date)) #Print out the day date
    print("Dessert served?: " + str(day.dessert_served)) #Print out if dessert is served (this will print either True or False)
    print("Pancakes served?: " + str(day.pancakes_served)) #Print out if pancakes are served (this will print either True or False)
    print("Hamburgers served?: " + str(day.burgers_served)) #Print out if hamburgers are served (this will print either True or False)
    print("---------------------------------------------------") #Print out a divider line
last_retrieved = menu.last_retrieved["json"] #Get when the menu was last retrieved
print("Menu retrieved: " + str(last_retrieved)) #Print out when the menu was last retrieved.

And now what...?

Learn more about the libary by reading the complete documentation. For more usage examples, click here. Also, make sure to check all available parameters to get from each Day object here. If you are planning to get images, you might want to read the About image caching page.

Last updated

Was this helpful?