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 yaledining
Then, to use these functions, you must import the module:
import yaledining
Before using the library, you must instantiate its class, for example:
api = yaledining.API()
# "api" name is just an example, this may be anything you desire
This API does not require authentication.
halls()
: get a list of all diningHall
s on campus.hall(id)
: get a singleHall
object 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 ofMeal
objects from a certain hall. Equivalent tomeals
, but with mandatoryhall_id
.managers([hall_id]): get a list of
Manager` objects, from a single hall if specified or for all halls if not.meals([hall_id], [date], [start_date], [end_date])
: get a list ofMeal
objects representing meals listed for thehall_id
specified, or all halls if omitted. Specifydate
to get meals for a certain date, orstart_date
andend_date
to get meals for an inclusive range of dates. Omit all three to get all meals.meal(id)
: get singleMeal
by ID.meal_items(meal_id)
: get a list of menuItem
s included in a meal with given ID.items([meal_id])
: get a list ofItem
s 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 # => 340
See 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
: getManager
s for this hall.meals([date], [start_date], [end_date])
: getMeal
s in this hall, providing date parameters as in standardmeals
call.
Manager
: a manager for a hall, stored insideHall
objects.Meal
: a single meal.items
: get menuItem
s in this meal.
Item
: a single menu item.nutrition
: shortcut to getNutrition
for 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.