Home

Awesome

db-zugradar-client

Deprecated because the Zugradar API has been shut off.


Get live departures of DB trains. With help from I like trains.

npm version build status ISC-licensed chat on gitter support me on Patreon

Installing

npm install db-zugradar-client

Usage

Note that you can only query for positions during the current day (in the Europe/Berlin timezone).

const {positions, route} = require('db-zugradar-client')

positions([when], [useHTTPS]) returns a Promise that will resolve with an array of trains, each looking like this:

{
	name: 'IC   842',
	id: '84/260080/18/19/80',
	previousStation: {
		type: 'station',
		id: '8503000',
		name: 'Zürich HB',
		departure: 1493416947 // UNIX timestamp
	},
	nextStation: {
		type: 'station',
		id: '8500218',
		name: 'Olten',
		arrival: 1493416947, // UNIX timestamp
		delay: 0
	},
	delay: 360,
	direction: {
		type: 'station',
		name: 'Bern'
	}
}

previousStation and nextStation are Friendly Public Transport Format station objects.

Given an id of a single train, route(id, [when], [useHTTPS]) returns a Promise that will resolve with a GeoJSON GeometryCollection, containing Points and LineStrings.

route('84/260080/18/19/80') // id property from above
.then(console.log, console.error)

Related

Contributing

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