Skip to content
Get live departures of DB trains.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.editorconfig
.gitignore
.travis.yml
example.js
index.js
license.md
package.json
positions.js
readme.md
route.js
test.js
todo

readme.md

db-zugradar-client

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)

Contributing

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.