Go API for OpenMensa
The openmensa
module functions purely as a library with no executables. To use it in a project, run
$ go get github.com/j0hax/go-openmensa
Following code snippet fetches today's menu and prices for a cafeteria in Hannover:
package main
import (
"fmt"
"github.com/j0hax/go-openmensa"
"log"
)
func main() {
// Contine Hannover has ID 7
contine, err := openmensa.GetCanteen(7)
if err != nil {
log.Fatal(err)
}
// Retrieve the current menu
menu, err := contine.CurrentMenu()
if err != nil {
log.Fatal(err)
}
// Print out structured data
fmt.Printf("%s: %s\n", contine.Name, menu.Day)
for _, meal := range menu.Meals {
price := meal.Prices["students"]
fmt.Printf("- %s (%0.2f€)\n", meal, price)
}
}
- OpenMensa's official API Documentation
- kiliankoe/openmensa, which I only discovered long after starting this project. It appears to be unmaintained.