This is an unofficial API module for accessing Swedish school lunch menus from skolmaten.se via Open Meal Information as specified at https://orebrokommun.github.io/Open-Meal-Information/.
Node.js, at least v10.13.0
.
Recommended to install latest via nvm:
nvm install stable
yarn add @hugojosefson/openmeal-api
# or
npm install --save @hugojosefson/openmeal-api
It is recommended to import
or require
the module, and use its exported functions programmatically.
- getDataProviders
- getDataProviderSkolmaten
- getDistributors
- filterDistributors
- getMeals
- extractOnlyMeals
Returns data providers.
dataprovidersJsonUrl
string url for the data providers json. Defaults to https://raw.githubusercontent.com/Orebrokommun/Open-Meal-Information/master/dataproviders.json as per https://orebrokommun.github.io/Open-Meal-Information/doc/list-data-providers.html
Returns Promise A Promise of the data
property of the response from the server.
Returns the data provider with name === 'Skolmaten'
.
dataprovidersJsonUrl
string url for the data providers json. Defaults to https://raw.githubusercontent.com/Orebrokommun/Open-Meal-Information/master/dataproviders.json as per https://orebrokommun.github.io/Open-Meal-Information/doc/list-data-providers.html
Returns Promise A Promise of the data
property of the response from the server.
Returns distributors from a data provider.
dataprovider
object data provider object to fetch distributors from.dataprovider.baseUrl
stringbaseUrl
of the data provider.
Returns Promise A Promise of the data
property of the response from the server.
Filters distributors based on partial name and/or partial address.
options
objectoptions.distributors
Array current distributors to filter, for example fromgetDistributors
or the result of previous call to this function.options.name
(string | undefined) if specified, only include distributors in result which contain this string in theirname
, case insensitively.options.address
(string | undefined) if specified, only include distributors in result which contain this string in theiraddressRegion
oraddressLocality
, case insensitively.
Returns Promise<Array> A Promise of an array of distributors matching the criteria.
Fetches meals for a distributor.
options
objectoptions.dataprovider
object data provider object to fetch distributors from.options.dataprovider.baseUrl
stringbaseUrl
of the data provider.
options.distributor
object distributor whose meals to fetch.options.distributor.distributorID
string the distributor's ID.
options.startDate
(string | undefined) start date on the formYYYY-MM-DD
.options.endDate
(string | undefined) end date on the formYYYY-MM-DD
.
Returns Promise A Promise of the data
property of the response from the server.
Extracts an array of only meals objects from a response from getMeals()
.
response
object response from callinggetMeals()
.
Returns Promise<Array> A Promise of an array containing all meal objects from the supplied response.
You can also try it from the command-line.
./node_modules/.bin/openmeal-api
Prints usage information for the CLI.