1.0.0 • Published 4 years ago

open-mensa v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

openmensa-js

OpenMensa is a free database for canteens. This package provides an easy point of entry to interface with the OpenMensa api in NodeJS.

const openmensa = require('openmensa-js');

openmensa.getCanteens({
  lng: 11.5933126,
  lat: 50.9243788,
  dist: 15,
}).then(canteens => { /*Do something*/ });

// or async-await syntax

const canteens = await openmensa.getCanteens({
  lng: 11.5933126,
  lat: 50.9243788,
  dist: 15,
});

// Do something

Methods

For more information on the API shemas and formats please refer to the offical OpenMensa documentation. All methods return promises.

getCanteens

method for requesting a list of canteens

openmensa.getCanteens(options);
NameTypeDescription
options.limitnumbermax number of canteens returned (default: 100 = max)
options.pagenumberoffset value to request more than the limit of 100 canteens
options.latnumbersearches for canteens near given coordinates
options.lngnumbersearches for canteens near given coordinates
options.distnumbermaximum distance to search for canteens near given coordinates (requires latitude and longitude)
options.idsarraylist of canteen IDs that should be returned
options.hasCoordinatesbooleanonly canteens with (true) or without (false) coordinates will be returned

getCanteen

method for requesting info about a single canteen

openmensa.getCanteen(id);
NameTypeDescription
idnumberthe canteen’s numeric ID

getDay

method for requesting opening information about a canteen on a specified date

openmensa.getDay(id, date);
NameTypeDescription
idnumberthe canteen’s numeric ID
dateDatedate

getDays

method for requesting opening information about a canteen

openmensa.getDays(id, options);
NameTypeDescription
idnumberthe canteen’s numeric ID
options.startdatestart date (default: today)
options.limitnumbermax number of days returned (default: 100 = max)

getMeals

method for requesting a list of available meals at a specified canteen on a specified day

openmensa.getMeals(id, date);
NameTypeDescription
idnumberthe canteen’s numeric ID
datedatedate

getMeal

method for requesting information on a specified meal at a specified canteen on a specified day

openmensa.getMeal(id, date, mealId);
NameTypeDescription
idnumberthe canteen’s numeric ID
datedatedate
mealIdnumberthe meals’s numeric ID
1.0.0

4 years ago