mensaapi

package module
v0.0.0-...-3572d65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2025 License: MIT Imports: 6 Imported by: 0

README

mensaapi

An unofficial golang API for the Studierendenwerk Ulms Mensa meal plans.

Installation

go get github.com/tiemingo/mensaapi

Available locations

Universität Ulm
- Mensa in der Uni Ulm
- Cafeteria Helmholtzstraße
- Cafeteria West 

Technische Hochschule Ulm
- THU Ulm Mensa
- THU Ulm Außenstelle Oberer Eselsberg Essensausgabe

Hochschule Aalen
- Mensa
- Cafeteria in der Hochschule

Pädagogische Hochschule Schwäbisch Gmünd
- Mensaria PH

Hochschule für Gestaltung Schwäbisch Gmünd
- Hochschule für Gestaltung Schwäbisch Gmünd

HBC. Biberach
- HBC. Biberach

Duale Hochschule Heidenheim
- Duale Hochschule Heidenheim

Example

package main

import (
	"fmt"
	"time"

	"github.com/tiemingo/mensaapi"
)

func main() {
	// day, err := mensaapi.GetDayByLocation(mensaapi.LOC_MENSA_UNI_ULM, mensaapi.ConvertStringToDate("2025-10-30"), mensaapi.LANGUAGE_GERMAN)
	day, err := mensaapi.GetDayByLocation(mensaapi.LOCATION_MENSA_UNI_ULM, time.Now(), mensaapi.LANGUAGE_GERMAN)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("---" + mensaapi.ConvertDateToString(day.Date) + "---")
	for category, items := range day.Categories {
		fmt.Println("---" + category + "---")
		for _, item := range items {
			fmt.Print("  ")
			if len(item.Additives.Tips) > 0 {
				fmt.Print("(")
				for _, v := range item.Additives.Tips {
					fmt.Print(mensaapi.GetTipDescription(v, mensaapi.LANGUAGE_GERMAN), ", ")
				}
				fmt.Print(") ")
			}
			fmt.Println(item.Name)
			if item.Info != "" {
				fmt.Println("	" + item.Info)
			}
			fmt.Println("	", item.Prices.PriceStudent, "€")
		}
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TipsMap = map[string]string{
	"veg": "Vegetarisch",
	"van": "Vegan",
	"bio": "Bio",
	"S":   "Schwein",
	"R":   "Rind",
	"L":   "Lamm",
	"W":   "Wildfleisch",
	"G":   "Geflügel",
	"F":   "Fisch",
	"T":   "Tintenfisch",
}
View Source
var TipsMapEn = map[string]string{
	"veg": "Vegetarian",
	"van": "Vegan",
	"bio": "Bio",
	"S":   "Pork",
	"R":   "Beef",
	"L":   "Lamb",
	"W":   "Game meat",
	"G":   "Poultry",
	"F":   "Fish",
	"T":   "Squid",
}

Functions

func ConvertDateToString

func ConvertDateToString(date time.Time) string

func ConvertStringToDate

func ConvertStringToDate(date string) time.Time

func GetTipDescription

func GetTipDescription(tip string, language Language) string

Returns the name of the tip or empty string if not found Example: S -> Schwein

Types

type Additives

type Additives struct {
	Allergenes []string
	Tips       []string // Food restrictions
}

type Day

type Day struct {
	Date       time.Time
	Categories map[string][]Item
}

func GetDayByLocation

func GetDayByLocation(loc Location, date time.Time, language Language) (Day, error)

Returns all menu items for the given date at the specified location

type Facility

type Facility int
const (
	FACILITY_UNI_ULM    Facility = 1 // Universität Ulm
	FACILITY_THU        Facility = 2 // Technische Hochschule Ulm
	FACILITY_HS_AALEN   Facility = 3 // Hochschule Aalen
	FACILITY_PAED_HS_SG Facility = 4 // Pädagogische Hochschule Schwäbisch Gmünd
	FACILITY_HS_GEST_SG Facility = 5 // Hochschule für Gestaltung Schwäbisch Gmünd
	FACILITY_HBC_BIB    Facility = 6 // HBC. Biberach
	FACILITY_DHS_HDH    Facility = 7 // Duale Hochschule Heidenheim
)

type Item

type Item struct {
	Category  string
	Name      string
	Info      string
	Prices    Prices
	Date      time.Time
	Additives Additives // Allergenes + Food restrictions
	Nutrition Nutrition
}

type Language

type Language string
const (
	LANGUAGE_GERMAN  Language = "de" // default
	LANGUAGE_ENGLISH Language = "en"
)

type Location

type Location int
const (
	// Universität Ulm
	LOCATION_MENSA_UNI_ULM        Location = 1  // Mensa in der Uni Ulm
	LOCATION_CAF_HELMHOLZ_UNI_ULM Location = 16 // Cafeteria Helmholtzstraße
	LOCATION_CAF_WEST_UNI_ULM     Location = 2  // Cafeteria West

	// Technische Hochschule Ulm
	LOCATION_MENSA_THU          Location = 3  // THU Ulm Mensa
	LOCATION_ESELSBERG_AUSG_THU Location = 10 // THU Ulm Außenstelle Oberer Eselsberg Essensausgabe

	// Hochschule Aalen
	LOCATION_MENSA_HS_AALEN      Location = 7 // Mensa
	LOCATION_CAF_BURREN_HS_AALEN Location = 5 // Cafeteria in der Hochschule

	// Pädagogische Hochschule Schwäbisch Gmünd
	LOCATION_MENSA_PAED_HS_SG Location = 4 // Mensaria PH

	//  Hochschule für Gestaltung Schwäbisch Gmünd
	LOCATION_HS_GEST_SG Location = 12 // Hochschule für Gestaltung Schwäbisch Gmünd

	// HBC. Biberach
	LOCATION_HBC_BIB Location = 6 // HBC. Biberach

	// Duale Hochschule Heidenheim
	LOCATION_DHS_HDH Location = 15 // Duale Hochschule Heidenheim
)

type Mensa

type Mensa struct {
	Locations map[string]MensaLocation
}

type MensaLocation

type MensaLocation struct {
	Name         string // Facility
	SubLocations map[string]Sublocation
}

type Nutrition

type Nutrition struct {
	Cal           float64
	Protein       float64
	Fat           float64
	PartSaturated float64
	Carbs         float64
	PartSuguar    float64
	Salt          float64
}

type Prices

type Prices struct {
	PriceStudent float64
	PriceWorker  float64
	PriceGuest   float64
}

type Sublocation

type Sublocation struct {
	Name   string // Location
	Legend map[string]string
	Days   map[time.Time]Item
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL