Giter Site home page Giter Site logo

derhuerst / wifi-on-ice-portal-client Goto Github PK

View Code? Open in Web Editor NEW
44.0 4.0 4.0 29 KB

Query information from the WifiOnICE portal in German ICE trains.

Home Page: https://github.com/derhuerst/wifi-on-ice-portal-client

License: ISC License

JavaScript 100.00%
ice deutsche-bahn db train wifionice

wifi-on-ice-portal-client's Introduction

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 support me via GitHub Sponsors chat with me on Twitter

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)
{
	serviceLevel: 'AVAILABLE_SERVICE',
	internet: 'HIGH',
	latitude: 51.2719795,
	longitude: 13.4613135,
	tileY: 141,
	tileX: 275,
	series: '411',
	serverTime: 1635252079700,
	speed: 0,
	trainType: 'ICE',
	tzn: 'Tz1178',
	wagonClass: 'FIRST',
	connectivity: {
		currentState: 'HIGH',
		nextState: 'UNSTABLE',
		remainingTimeSeconds: 3600
	},
	bapInstalled: true,
	ok: true,
	gpsOk: true
}

API

portal.status()

Returns a Promise.

portal.journey()

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

{
	public: true,
	mode: 'train',
	line: { type: 'line', id: 'ice-1556', name: 'ICE 1556' },
	traveledDistance: 44502,
	distanceToPreviousStop: 62523,
	totalDistance: 436961,
	next: {
		type: 'station',
		id: '8010205_00',
		name: 'Leipzig Hbf',
		location: { type: 'location', latitude: 51.345471, longitude: 12.382064 }
	},
	scheduledNext: {
		type: 'station',
		id: '8010205_00',
		name: 'Leipzig Hbf',
		location: { type: 'location', latitude: 51.345471, longitude: 12.382064 }
	},
	previous: {
		type: 'station',
		id: '8010297_00',
		name: 'Riesa',
		location: { type: 'location', latitude: 51.309654, longitude: 13.287734 }
	},
	last: {
		type: 'station',
		id: '8070003_00',
		name: 'Frankfurt (M) Flughafen Fernbf',
		location: { type: 'location', latitude: 50.053167, longitude: 8.570185 }
	},
	passed: [
		{
			station: {
				type: 'station',
				id: '8010085_00',
				name: 'Dresden Hbf',
				location: { type: 'location', latitude: 51.040563, longitude: 13.732035 }
			},
			arrival: null,
			arrivalDelay: null,
			arrivalPlatform: '3',
			departure: '2021-10-26T14:16:00+02:00',
			departureDelay: 300,
			departurePlatform: '3',
			passed: true,
			kmFromStart: 0,
			delayReasons: null
		},
		{
			station: {
				type: 'station',
				id: '8010089_00',
				name: 'Dresden-Neustadt',
				location: { type: 'location', latitude: 51.065899, longitude: 13.740701 }
			},
			arrival: '2021-10-26T14:20:00+02:00',
			arrivalDelay: 300,
			arrivalPlatform: '6',
			departure: '2021-10-26T14:22:00+02:00',
			departureDelay: 300,
			departurePlatform: '6',
			passed: true,
			kmFromStart: 2.882,
			delayReasons: [ { code: '36', text: 'Reparatur am Zug' } ]
		},
		// ...
		{
			station: {
				type: 'station',
				id: '8000105_00',
				name: 'Frankfurt (Main) Hbf',
				location: { type: 'location', latitude: 50.107145, longitude: 8.663789 }
			},
			arrival: '2021-10-26T18:38:00+02:00',
			arrivalDelay: 120,
			arrivalPlatform: '7',
			departure: '2021-10-26T18:44:00+02:00',
			departureDelay: 120,
			departurePlatform: '7',
			passed: false,
			kmFromStart: 427.979,
			delayReasons: [ { code: '36', text: 'Reparatur am Zug' } ]
		},
		{
			station: {
				type: 'station',
				id: '8070003_00',
				name: 'Frankfurt (M) Flughafen Fernbf',
				location: { type: 'location', latitude: 50.053167, longitude: 8.570185 }
			},
			arrival: '2021-10-26T18:57:00+02:00',
			arrivalDelay: 120,
			arrivalPlatform: 'Fern 7',
			departure: null,
			departureDelay: null,
			departurePlatform: 'Fern 7',
			passed: false,
			kmFromStart: 436.961,
			delayReasons: [ { code: '36', text: 'Reparatur am Zug' } ]
		}
	]
}

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.

wifi-on-ice-portal-client's People

Contributors

derhuerst avatar hannsadrian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wifi-on-ice-portal-client's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.