All Projects → public-transport → vbb-hafas

public-transport / vbb-hafas

Licence: ISC license
A JavaScript client for Berlin & Brandenburg public transport HAFAS API.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vbb-hafas

bvg-topological-map
BVG transport map as a nice SVG.
Stars: ✭ 15 (-46.43%)
Mutual labels:  transit, berlin, transport, vbb, bvg
vbb-rest
An HTTP API for Berlin & Brandenburg public transport.
Stars: ✭ 104 (+271.43%)
Mutual labels:  transit, berlin, transport, vbb, bvg
VBBNow
A VBB NotificationCenter Widget. It shows the nearby transit information
Stars: ✭ 23 (-17.86%)
Mutual labels:  transit, berlin, vbb, bvg
MMM-PublicTransportBerlin
MagicMirror module to display public transport in Berlin and Brandenburg with BVG Hafas data.
Stars: ✭ 37 (+32.14%)
Mutual labels:  berlin, vbb, bvg
open-bus
🚌 Analysing Israel's public transport data
Stars: ✭ 65 (+132.14%)
Mutual labels:  transit, transport
public-transit-tools
Tools for working with GTFS public transit data in ArcGIS
Stars: ✭ 126 (+350%)
Mutual labels:  transit, transport
db-hafas
JavaScript client for the Deutsche Bahn HAFAS API.
Stars: ✭ 54 (+92.86%)
Mutual labels:  transit, transport
European Transport Modules
[DISCONTINUED in favour of public-transport-operators] Collection of european transport JavaScript modules.
Stars: ✭ 9 (-67.86%)
Mutual labels:  transit, transport
european-transport-operators
NOT UP-TO-DATE ANYMORE, UNMAINTAINED. CHECK european-transport-feeds INSTEAD. List of european long-distance transport operators, available API endpoints, GTFS feeds and client modules.
Stars: ✭ 47 (+67.86%)
Mutual labels:  transit, transport
ideas
How to make public transport more comfortable, more accessible, more transparent?
Stars: ✭ 35 (+25%)
Mutual labels:  transit, transport
db-stations
A list of DB stations.
Stars: ✭ 15 (-46.43%)
Mutual labels:  transit, transport
citylines
Citylines.co is a collaborative platform for mapping the transit systems of the world!
Stars: ✭ 53 (+89.29%)
Mutual labels:  transit, transport
matsim-sbb-extensions
matsim swiss rail
Stars: ✭ 23 (-17.86%)
Mutual labels:  transit, transport
TrenitaliaAPI
Reverse engineering dell'API dell'app di Trenitalia
Stars: ✭ 32 (+14.29%)
Mutual labels:  transit, transport
Tidytransit
R package for working with the General Transit Feed Specification (GTFS)
Stars: ✭ 84 (+200%)
Mutual labels:  transit, transport
Vbb Cli
A CLI for Berlin & Brandenburg public transport.
Stars: ✭ 70 (+150%)
Mutual labels:  transit, transport
waka
Your realtime guide to public transport in New Zealand
Stars: ✭ 37 (+32.14%)
Mutual labels:  transit, transport
Vbb Modules
List of JavaScript modules for Berlin & Brandenburg public transport.
Stars: ✭ 47 (+67.86%)
Mutual labels:  transit, transport
Hafas Client
JavaScript client for HAFAS public transport APIs.
Stars: ✭ 125 (+346.43%)
Mutual labels:  transit, transport
transxchange2gtfs
tool to convert transxchange data into a GTFS feed
Stars: ✭ 26 (-7.14%)
Mutual labels:  transit, transport

vbb-hafas

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

This project is actually a thin wrapper around hafas-client@6. Its docs document the API in general.

Note: You may not want to query the VBB API by yourself. vbb-client is an API-compatible client for vbb-rest, my wrapper API. It also works in the browser.

npm version build status ISC-licensed minimum Node.js version support Jannis via GitHub Sponsors chat with Jannis on Twitter

Installing

npm install vbb-hafas

API

Check the docs for hafas-client as well as its VBB-specific customisations.

Usage

const createHafas = require('vbb-hafas')

const hafas = createHafas('my-awesome-program')

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

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

The output will be an array of journey objects in the Friendly Public Transport Format 1.2.1 format:

[ {
	legs: [ {
		tripId: '1|50420|0|86|25122017',
		direction: 'Brandenburg, Hbf',
		line: {
			type: 'line',
			id: '10',
			name: 'RE1',
			public: true,
			mode: 'train',
			product: 'regional',
			symbol: 'RE',
			nr: 1,
			metro: false,
			express: true,
			night: false,
			class: 64,
			productCode: 6,
			operator: {
				type: 'operator',
				id: 'db-regio-ag',
				name: 'DB Regio AG'
			}
		},

		origin: {
			type: 'station',
			id: '900000003201',
			name: 'S+U Berlin Hauptbahnhof',
			location: {
				type: 'location',
				latitude: 52.52585,
				longitude: 13.368928
			},
			products: {
				suburban: true,
				subway: true,
				tram: true,
				bus: true,
				ferry: false,
				express: true,
				regional: true
			}
		},
		departure: '2017-12-26T00:41:00.000+01:00',
		plannedDeparture: '2017-12-26T00:41:00.000+01:00',
		departureDelay: 0,
		departurePlatform: '14',
		plannedDeparturePlatform: '13',

		destination: {
			type: 'station',
			id: '900000024101',
			name: 'S Charlottenburg',
			location: {
				type: 'location',
				latitude: 52.504806,
				longitude: 13.303846
			},
			products: {
				suburban: true,
				subway: false,
				tram: false,
				bus: true,
				ferry: false,
				express: false,
				regional: true
			}
		},
		arrival: '2017-12-26T00:50:00.000+01:00',
		plannedArrival: '2017-12-26T00:50:00.000+01:00',
		arrivalDelay: null,
		arrivalPlatform: '4',
		plannedArrivalPlatform: '4'
	} ],

	// all these are from the first leg
	origin: {
		type: 'station',
		id: '900000003201',
		name: 'S+U Berlin Hauptbahnhof'
		// …
	},
	departure: '2017-12-26T00:41:00.000+01:00',
	plannedDeparture: '2017-12-26T00:41:00.000+01:00',
	departureDelay: 0,
	departurePlatform: '14',
	plannedDeparturePlatform: '13',

	// all these are from the last leg
	destination: {
		type: 'station',
		id: '900000024101',
		name: 'S Charlottenburg'
		// …
	},
	arrival: '2017-12-26T00:50:00.000+01:00',
	plannedArrival: '2017-12-26T00:50:00.000+01:00',
	arrivalDelay: null,
	arrivalPlatform: '4',
	plannedArrivalPlatform: '4'

	// …
} ]

Transfer information for journeys

vbb-hafas will try to add transfer information from vbb-change-positions if you pass transferInfo: true as an option.

If it identifies a known transfer, the previous leg will have a bestArrivalPosition and the next leg will have a departurePosition, indicating the optimal transfer between both platforms. Check out the markup in vbb-change-positions for more details.

Related

Check hafas-client's related projects.

Contributing

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].