wifi-on-ice-portal-client

1.0.0 • Public • Published

wifi-on-ice-portal-client

Query information from the WifiOnICE portal in German ICE trains.

A lot of the features of the portal are not covered yet.

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

Installing

npm install wifi-on-ice-portal-client

Usage

const portal = require('wifi-on-ice-portal-client')

portal.status()
.then(console.log)
.catch(console.error)
{
	ok: true,
	speed: 245,
	gpsOk: true,
	latitude: 51.86973533333333,
	longitude: 9.989614166666666,
	servicelevel: 'AVAILABLE_SERVICE',
	wagonClass: 'FIRST',
	serverTime: 1504698041985
}

API

portal.status()

Returns a Promise.

portal.journey()

Returns a Promise that resolves with a Friendly Public Transport Format 1.0.1 journey leg, similar to db-hafas. It looks like this:

{
	public: true,
	mode: 'train',
	line: {
		type: 'line',
		id: 'ice-599',
		name: 'ICE 599'
	},
	next: {
		type: 'station',
		id: '8000128_00',
		name: 'Göttingen',
		location: {
			type: 'location',
			latitude: 51.536815,
			longitude: 9.926072
		}
	},
	scheduledNext: {
		type: 'station',
		id: '8000128_00',
		name: 'Göttingen',
		location: {
			type: 'location',
			latitude: 51.536815,
			longitude: 9.926072
		}
	},
	previous: {
		type: 'station',
		id: '8000169_00',
		name: 'Hildesheim Hbf',
		location: {
			type: 'location',
			latitude: 52.160626,
			longitude: 9.953497
		}
	},
	last: {
		type: 'station',
		id: '8000261_00',
		name: 'München Hbf',
		location: {
			type: 'location',
			latitude: 48.140232,
			longitude: 11.558335
		}
	},
	passed: [{
		station: {
			type: 'station',
			id: '8010255_00',
			name: 'Berlin Ostbahnhof',
			location: {
				type: 'location',
				latitude: 52.510977,
				longitude: 13.434564
			}
		},
		arrival: null,
		arrivalDelay: null,
		arrivalPlatform: '6',
		departure: '2017-09-06T11:22:00+02:00',
		departureDelay: 0,
		departurePlatform: '6',
		passed: true,
		kmFromStart: 0
	}, {
		station: {
			type: 'station',
			id: '8011160_00',
			name: 'Berlin Hbf',
			location: {
				type: 'location',
				latitude: 52.525592,
				longitude: 13.369545
			}
		},
		arrival: '2017-09-06T11:30:00+02:00',
		arrivalDelay: 0,
		arrivalPlatform: '14',
		departure: '2017-09-06T11:34:00+02:00',
		departureDelay: 0,
		departurePlatform: '14',
		passed: true,
		kmFromStart: 4.691
	},
	// …
	{
		station: {
			type: 'station',
			id: '8004158_00',
			name: 'München-Pasing',
			location: {
				type: 'location',
				latitude: 48.149852,
				longitude: 11.461872
			}
		},
		arrival: '2017-09-06T19:29:00+02:00',
		arrivalDelay: 120,
		arrivalPlatform: '9',
		departure: '2017-09-06T19:31:00+02:00',
		departureDelay: 120,
		departurePlatform: '9',
		passed: false,
		kmFromStart: 881.612
	}, {
		station: {
			type: 'station',
			id: '8000261_00',
			name: 'München Hbf',
			location: {
				type: 'location',
				latitude: 48.140232,
				longitude: 11.558335
			}
		},
		arrival: '2017-09-06T19:38:00+02:00',
		arrivalDelay: 120,
		arrivalPlatform: '14',
		departure: null,
		departureDelay: null,
		departurePlatform: '14',
		passed: false,
		kmFromStart: 888.851
	}]
}

Related

Contributing

If you have a question or have difficulties using wifi-on-ice-portal-client, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

Package Sidebar

Install

npm i wifi-on-ice-portal-client@1.0.0

Version

1.0.0

License

ISC

Unpacked Size

9.74 kB

Total Files

4

Last publish

Collaborators

  • derhuerst