Python library for obtaining Yale Dining data via the YaleDine API.
NOTE: The legacy Yale Dining API has been deprecated and Yale is not updating the data it provides. As of v2, this package instead uses the YaleDine API, an unofficial student project that scrapes Yale's various dining websites and provides clean and standardized JSON-formatted menus.
First, install the module:
pip3 install yalediningThen, to use these functions, you must import the module:
import yalediningBefore using the library, you must instantiate its class, for example:
api = yaledining.API()
# "api" name is just an example, this may be anything you desireThis API does not require authentication.
halls(): get a list of all diningHalls on campus.hall(id): get a singleHallobject by ID (two-letter abbreviation).hall_managers(hall_id): get managers for aHall.hall_meals(hall_id, [date], [start_date], [end_date]): get a list ofMealobjects from a certain hall. Equivalent tomeals, but with mandatoryhall_id.managers([hall_id]): get a list ofManager` objects, from a single hall if specified or for all halls if not.meals([hall_id], [date], [start_date], [end_date]): get a list ofMealobjects representing meals listed for thehall_idspecified, or all halls if omitted. Specifydateto get meals for a certain date, orstart_dateandend_dateto get meals for an inclusive range of dates. Omit all three to get all meals.meal(id): get singleMealby ID.meal_items(meal_id): get a list of menuItems included in a meal with given ID.items([meal_id]): get a list ofItems served in a given meal, or all items.item_nutrition(item_id): get nutrition data for a menu item.
Note that it almost always cleaner to use builder syntax such as:
meal = api.hall('GH').meals(datetime.date.today())[0]
item = meal.items[0]
item.nutrition.calories # => 340See more examples in example.py.
Models follow the schema listed in the YaleDine API documentation. Shortcut methods provided by this package are listed below for your convenience.
Hall: a dining hall.managers: getManagers for this hall.meals([date], [start_date], [end_date]): getMeals in this hall, providing date parameters as in standardmealscall.
Manager: a manager for a hall, stored insideHallobjects.Meal: a single meal.items: get menuItems in this meal.
Item: a single menu item.nutrition: shortcut to getNutritionfor the item.
Nutrition: index of nutrition facts for anItem.
See example.py for several usage examples.
This software is not endorsed by Yale Dining, Yale Hospitality, or Yale University.