This API provides access to the current menu data from all Studierendenwerk Mainz cafeterias and dining halls. It scrapes the official website and returns the data in a clean, structured JSON format, organized by days and locations.
menu.php file to your desired locationGET https://your-domain.com/menu.php?display_type=1
| Parameter | Values | Description |
|---|---|---|
display_type |
1, 2, or 3 |
|
{
"meta": {
"display_type": 1,
"timestamp": 1704636789
},
"days": [
{
"date": "2025-01-07",
"locations": [
{
"name": "Zentralmensa",
"closed": false,
"meals": [
{
"name": "Meal name",
"price_student": 3.58,
"price_staff": 5.93,
"attributes": [
"vegetarian",
"climate_friendly",
"contains_gluten"
],
"co2_value": 1569
}
]
}
]
}
]
}
| Field | Type | Description |
|---|---|---|
meta.display_type |
integer | The requested display type (1, 2, or 3) |
meta.timestamp |
integer | Unix timestamp of when the response was generated |
days |
array | Array of day objects, each containing locations and their menus |
days[].date |
string | ISO 8601 formatted date (YYYY-MM-DD) |
days[].locations |
array | Array of locations available on this date |
location.name |
string | Name of the dining location |
location.closed |
boolean | Whether the location is closed on this date |
location.meals |
array | Array of meal objects available at this location |
| Attribute | Description |
|---|---|
vegan |
Meal is vegan |
vegetarian |
Meal is vegetarian |
climate_friendly |
Meal is climate-friendly |
contains_gluten |
Contains gluten |
contains_lactose |
Contains lactose |
contains_fish |
Contains fish |
contains_pork |
Contains pork |
contains_beef |
Contains beef |
contains_chicken |
Contains chicken |
curl "https://your-domain.com/menu.php?display_type=1"
curl "https://your-domain.com/menu.php?display_type=2"
curl "https://your-domain.com/menu.php?display_type=3"
async function getMenu(displayType = 1) {
const response = await fetch(`https://your-domain.com/menu.php?display_type=${displayType}`);
const data = await response.json();
// Access first day's data
const firstDay = data.days[0];
console.log(`Menu for ${firstDay.date}:`, firstDay.locations);
// Example: Get all open locations for a specific day
const openLocations = firstDay.locations
.filter(location => !location.closed)
.map(location => location.name);
// Example: Get all vegan meals from all locations
const veganMeals = firstDay.locations
.flatMap(location => location.meals)
.filter(meal => meal.attributes?.includes('vegan'));
return data;
}
Important:
The API includes CORS headers and allows requests from any origin. If you need to restrict access, modify the following line in menu.php:
header('Access-Control-Allow-Origin: *');
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.