Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steve2955/openmensa-js
A NodeJS API wrapper for openmensa.org
https://github.com/steve2955/openmensa-js
openmensa openmensa-api
Last synced: 22 days ago
JSON representation
A NodeJS API wrapper for openmensa.org
- Host: GitHub
- URL: https://github.com/steve2955/openmensa-js
- Owner: Steve2955
- License: gpl-3.0
- Created: 2020-06-11T13:34:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T23:57:39.000Z (almost 2 years ago)
- Last Synced: 2024-04-25T04:02:40.147Z (9 months ago)
- Topics: openmensa, openmensa-api
- Language: JavaScript
- Homepage:
- Size: 237 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# openmensa-js
[OpenMensa](https://openmensa.org/) is a free database for canteens. This package provides an easy point of entry to interface with the OpenMensa api in NodeJS.
## Installation
```shell
npm install openmensa-js
```## Example
```js
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](https://doc.openmensa.org/api/v2/).
All methods return promises.### getCanteens
method for requesting a list of canteens
```js
openmensa.getCanteens(options);
```| Name | Type | Description |
|------------------------|---------|--------------------------------------------------------------------------------------------------|
| options.limit | number | max number of canteens returned (default: 100 = max) |
| options.page | number | offset value to request more than the limit of 100 canteens |
| options.lat | number | searches for canteens near given coordinates |
| options.lng | number | searches for canteens near given coordinates |
| options.dist | number | maximum distance to search for canteens near given coordinates (requires latitude and longitude) |
| options.ids | array | list of canteen IDs that should be returned |
| options.hasCoordinates | boolean | only canteens with (true) or without (false) coordinates will be returned |### getCanteen
method for requesting info about a single canteen
```js
openmensa.getCanteen(id);
```| Name | Type | Description |
|------------|---------|-----------------------------|
| id | number | the canteen’s numeric ID | |### getDay
method for requesting opening information about a canteen on a specified date
```js
openmensa.getDay(id, date);
```| Name | Type | Description |
|----------|---------|----------------------------|
| id | number | the canteen’s numeric ID |
| date | Date | date |### getDays
method for requesting opening information about a canteen
```js
openmensa.getDays(id, options);
```| Name | Type | Description |
|------------------------|---------|----------------------------------------------------|
| id | number | the canteen’s numeric ID |
| options.start | date | start date (default: today) |
| options.limit | number | max number of days returned (default: 100 = max) |### getMeals
method for requesting a list of available meals at a specified canteen on a specified day
```js
openmensa.getMeals(id, date);
```| Name | Type | Description |
|------------------------|---------|----------------------------------------------------|
| id | number | the canteen’s numeric ID |
| date | date | date |### getMeal
method for requesting information on a specified meal at a specified canteen on a specified day
```js
openmensa.getMeal(id, date, mealId);
```| Name | Type | Description |
|------------------------|---------|----------------------------------------------------|
| id | number | the canteen’s numeric ID |
| date | date | date |
| mealId | number | the meals’s numeric ID |