Skip to content
Pass in a HAFAS client, fetch all departures at any set of stations.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

hafas-monitor-departures 🔭

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 version build status ISC-licensed gitter channel support me on Patreon


npm install hafas-monitor-departures


As an exampe, we're going to use vbb-hafas, the HAFAS client for Berlin.

const createMonitor = require('hafas-monitor-departures')
const createHafas = require('vbb-hafas')

const stations = ['900000100003'] // array of station ids
const interval = 2 * 60 * 1000 // every two minutes

const hafas = createHafas('my-awesome-program')
const departures = createMonitor(hafas, stations, interval)
.on('error', console.error)
.on('data', console.log)

setTimeout(() => {
	departures.stop() // stop querying
}, interval * 3)

createMonitor will call hafas.departures() and writes each of the returned departures into the stream. It expects departures() to be compatible with the implementation from hafas-client.

Note: A stream created by calling createMonitor(…) does not stop calling the API if you unpipe it. You need to manually call departures.stop().

To manually issue a single departures check at a station, use departures.manual(id). The result will be emitted in a data event like all others.



If you have a question, found a bug or want to propose a feature, have a look at the issues page.

You can’t perform that action at this time.