This package has been deprecated

Author message:

Use hafas-monitor-departures with db-hafas instead.

db-monitor

0.2.0 • Public • Published

db-monitor 🔭

Fetch departures at DB stations. (You may get blacklisted.)

npm version build status ISC-licensed gitter channel

Installing

npm install db-monitor

Usage

const monitor = require('db-monitor')
 
const stations = ['8002553'] // array of station ids
const interval = 10 * 1000 // every 10 seconds
 
const departures = monitor(stations, interval)
departures.on('error', console.error)
departures.on('data', console.log)
 
setTimeout(() => {
    departures.stop() // stop querying
}, interval * 3)

The stream will emit Friendly Public Transport Format 1.0.1 departures that look like this:

{
    when: '2017-05-22T14:47:00+02:00',
    delay: 480,
    station: {
        type: 'station',
        id: '692757'
        name: 'Bahnhof Altona, Hamburg',
        location: {
            type: 'location',
            latitude: 53.551663,
            longitude: 9.934231
        },
        products: // …
    },
    line: {
        type: 'line',
        id: 'bus-283',
        name: 'Bus 283',
        mode: 'bus',
        product: 'bus'
    },
    trip: 329143,
    direction: 'Langenfelder Damm, Hamburg'
}
// …
{
    when: '2017-05-22T15:02:00+02:00',
    delay: 0,
    station: {
        type: 'station',
        id: '8098553',
        name: 'Hamburg-Altona(S)',
        location: {
            type: 'location',
            latitude: 53.551267,
            longitude: 9.934698
        },
        products: // …
    },
    line: {
        type: 'line',
        id: 's-1',
        name: 'S 1',
        mode: 'train',
        product: 'suburban'
    },
    trip: 247000,
    direction: 'Wedel(Holst)'
}

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

Contributing

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

Package Sidebar

Install

npm i db-monitor

Weekly Downloads

1

Version

0.2.0

License

ISC

Last publish

Collaborators

  • derhuerst