vbb-hafas
JavaScript client for the VBB HAFAS API.
Last updated 20 days ago by derhuerst .
ISC · Repository · Bugs · Original npm · Tarball
$ cnpm install vbb-hafas 
SYNC missed versions from official npm registry.

vbb-hafas

A client for the Berlin & Brandenburg public transport service (VBB). It acts as a consistent and straightforward promise-based interface on top of the verbose HAFAS API.

Note: Almost certainly, vbb-client is what you are looking for (it queries vbb-rest). It is more feature-rich and lightweight.

npm version build status dependency status dev dependency status ISC-licensed

Installing

npm install vbb-hafas

Getting Started

const hafas = require('vbb-hafas')

As an example, we will search for a journey from Berlin Hauptbahnhof to Berlin Charlottenburg. To get the station ids, use vbb-stations.

client.journeys('900000003201', '900000024101', {results: 1})
.then((journeys) => console.log(journeys[0]))

The output will be in the Friendly Public Transport Format:

[
	{
		type: 'journey',
		// taken from the first part
		origin: {
			type: 'station',
			id: '900000003201',
			name: 'S+U Berlin Hauptbahnhof',
			coordinates: {latitude: 52.52585, longitude: 13.368928},
			products: // …
		},
		departure: '2017-05-16T13:31:00+02:00',
		// taken from the last part
		destination: {
			type: 'station',
			id: '900000024101',
			name: 'S Charlottenburg',
			coordinates: {latitude: 52.505049, longitude: 13.305213},
			products: // …
		},
		arrival: '2017-05-16T13:41:00+02:00',
		parts: [{
			origin: {
				type: 'station',
				id: '900000003201',
				name: 'S+U Berlin Hauptbahnhof',
				coordinates: {latitude: 52.52585, longitude: 13.368928},
				products: // …
			},
			departure: '2017-05-16T13:31:00+02:00',
			departurePlatform: '16',
			destination: {
				type: 'station',
				id: '900000024101',
				name: 'S Charlottenburg',
				coordinates: {latitude: 52.505049, longitude: 13.305213},
				products: // …
			},
			arrival: '2017-05-16T13:41:00+02:00',
			delay: 0,
			line: {
				type: 'line',
				id: 's75',
				name: 'S75',
				mode: 'train',
				product: 'suburban',
				class: 1,
				productCode: 0,
				productName: 'S-7',
				symbol: 'S',
				nr: 75,
				metro: false,
				express: false,
				night: false
			},
			arrivalPlatform: '8'
			direction: 'S Westkreuz',
		}]
	}
]

Contributing

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

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 21
Last Day 0
Last Week 0
Last Month 49
Dependencies (11)
Dev Dependencies (5)

Copyright 2014 - 2017 © taobao.org |