Pass in a HAFAS client, fetch all departures at any set of stations. (You may get blacklisted.)
If you want to monitor trips/departures in an area, use
hafas-monitor-trips. It polls HAFAS more efficiently.
npm install hafas-monitor-departures
As an exampe, we're going to use
vbb-hafas, the HAFAS client for Berlin.
const createMonitor =const createHafas =const stations = '900000100003' // array of station idsconst interval = 2 * 60 * 1000 // every two minutesconst duration = 10 // each time, fetch departures for the next 10 minconst hafas =const monitor =monitormonitor
Once you listen to any of the
stats events, it will automatically start to watch, and stop once you stop listening.
To manually issue a single departures check at a station, use
monitor.manual(id). The result will be emitted in a data event like all others.
opt overrides the following default values:
interval: interval || 60 * 1000step: step || Mathduration: duration || Math
hafas-record-delays– Record delays from
hafas-monitor-departuresinto a LevelDB.
record-vbb-delays– Record VBB departures from HAFAS.
hafas-monitor-trips– Using a HAFAS endpoint, watch all trips in a bounding box.
hafas-monitor-trips-server– A server that manages
If you have a question, found a bug or want to propose a feature, have a look at the issues page.