0.0.6 • Published 4 years ago

simplifyefa v0.0.6

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

SimplifyEFA

Installation

You can install using npm.

npm install simplifyefa

Endpoint

The EFA endpoint can be set when creating an instance of the SimplifyEfa class, the endpoint in the example below is set by default when you omit the parameter:

const simplifyEfa = new SimplifyEfa('https://openservice-test.vrr.de/static02')

Departure Monitor

The departure monitor requests the next departures for the given stop id starting at the given time. Only departures of services matching the given modes of transport are requested. Stop ids can be obtained using the station finder. The example below lists the next 40 regional train and S-Bahn departures out of Düsseldorf Hbf, also informing about delays:

simplifyEfa.departureMonitor(20018235, new Date(), [ModeOfTransport.REGIONAL_RAILWAY], 40)
  .then((departures) => {
    for (const departure of departures) {
      console.log(`${departure.servingLine.lineNumber} leaving for
                   ${departure.servingLine.directionTo} at ${departure.dateTime}`)

      // Check if we have real-time data and there is a delay.
      if (departure.realDateTime !== undefined &&
          departure.realDateTime != departure.dateTime) {
        console.log(` > Delayed! Actual time of departure is ${departure.realDateTime}`)
      }
    }
  })
  .catch(function (error) {
    // Request failed
  });

Modes of Transport

Filtering departures is possible with the values of the mode of transport enumeration:

Enumeration ValueGerman TranslationComments
RAILWAYZügeCombination ofREGIONAL_RAILWAY,NATIONAL_RAILWAY,INTERNATIONAL_RAILWAYand HIGH_SPEED_RAILWAY
URBAN_RAILWAYS-Bahnen
METROU-Bahnen
CITY_RAILWAYStadtbahnen
TRAMStraßenbahnen
CITY_BUSStadtbusse
REGIONAL_BUSRegionalbusse
EXPRESS_BUSExpressbusse
CABLE_AND_COG_RAILWAYSeil- und Zahnradbahnen
AST_ON_CALL_BUSAST und Rufbusse
SUSPENSION_RAILWAYSchwebebahnen
AIRPLANEFlugzeuge
REGIONAL_RAILWAYIRE, RE, RB
NATIONAL_RAILWAYIR, D
INTERNATIONAL_RAILWAYIC, EC
HIGH_SPEED_RAILWAYICE
RAIL_REPLACEMENT_SERVICESchienenersatzverkehr
SHUTTLE_RAILWAYShuttlezüge
CITIZENS_BUSBürgerbusse

Station Finder

The station finder allows requesting station information for a given query string. It can be used to find the stop ids required for requests to the departure monitor. The search algorithm isn't as good, while searching for 'Düsseldorf Hbf' returns the only one correct station, searching for 'Düsseldorf Derendorf' does return multiple stations but not the one we are searching for. An example usage is given below:

simplifyEfa.stationFinder('Düsseldorf Hbf')
  .then((stations) => {
    for (const station of stations) {
      console.log(`Found ${station.name} with id ${station.stopId}`)
    }
  })
  .catch(function (error) {
    // Request failed
 });

Status

For the moment, the wrapper has only been tested against the EFA endpoint of the VRR, which is also used by default when constructing a SimplifyEfa object. Also, only the station finder and departure monitor functionality have been implemented for now.

Links

  • Official EFA documentation by the Verkehrsverbund Rhein-Ruhr (VRR): Link
  • Documentation of the EFA JSON interface by Münsterhack: Link
  • Wikipedia article about EFA: Link
0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago