CS50’s Dining API provides programmatic access via HTTP to data from Harvard University Dining Services (HUDS), including menus for
The API expects requests via GET (or HEAD).
On success, the API returns data in JSON format with an HTTP status code of 200.
On failure, the API returns an HTTP status code of
- 400, if an endpoint wasn’t used properly, or
- 404, if an endpoint doesn’t exist.
Returns a JSON array of objects, each of which represents a location on campus. For example, https://api.cs50.io/dining/locations.
Returns a JSON object that represents a location on campus. For example, https://api.cs50.io/dining/locations/30 represents Annenberg Hall, while https://api.cs50.io/dining/locations/7 represents Dunster and Mather House. Because some dining halls (e.g., Dunster’s and Mather’s) share kitchens (and thus menus), they also share an
name) in the API.
Returns a JSON array of objects, each of which represents a category of food. For example, https://api.cs50.io/dining/categories.
Returns a JSON object that represents a category, where
:id is that category’s
id. For example, https://api.cs50.io/dining/categories/32 represents Fresh Fruit, whereas https://api.cs50.io/dining/categories/62 represents Daily Soups. Yum!
Returns a JSON array of objects, each of which represents a recipe. For example, https://api.cs50.io/dining/recipes.
Returns a JSON object that represents a recipe. For example, https://api.cs50.io/dining/recipes/22011 represents Kabocha Squash Soup, whereas https://api.cs50.io/dining/recipes/22045 represents Wheat Tortillas. Yum!
- Undergraduate dining halls span, of course, multiple locations. Accordingly, you can get today’s menus for undergraduate dining halls with a (long!) URL like https://api.cs50.net/dining/menus?category=1&category=2&category=3&category=4&category=5&category=7&category=10&category=11&category=13&category=14&category=15&category=16&category=17&category=18&category=19&category=20&category=22&category=23&category=24&category=25&category=26&category=27&category=29&category=32&category=45&category=46&category=60&category=90&location=5&location=7&location=8&location=9&location=14&location=15&location=16&location=30&location=38.
- Bagged meals for undergraduates are only available at some locations (i.e., undergraduate dining halls), and their recipes are in multiple categories. Accordingly, you can GET them via a (long!) URL like https://api.cs50.io/dining/menus?category=87&category=91&category=92&category=93&category=94&category=95&category=96&category=97&location=5&location=7&location=8&location=9&location=14&location=15&location=16&location=30&location=38.
- Fly-By is implemented as a location. Accordingly, you can GET today’s Fly-By’s menu via a URL like https://api.cs50.io/dining/menus?location=29.