All Projects → public-transport → db-hafas

public-transport / db-hafas

Licence: ISC license
JavaScript client for the Deutsche Bahn HAFAS API.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to db-hafas

db-stations
A list of DB stations.
Stars: ✭ 15 (-72.22%)
Mutual labels:  transit, germany, transport, deutsche-bahn
public-transit-tools
Tools for working with GTFS public transit data in ArcGIS
Stars: ✭ 126 (+133.33%)
Mutual labels:  transit, transport
citylines
Citylines.co is a collaborative platform for mapping the transit systems of the world!
Stars: ✭ 53 (-1.85%)
Mutual labels:  transit, transport
waka
Your realtime guide to public transport in New Zealand
Stars: ✭ 37 (-31.48%)
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 (-12.96%)
Mutual labels:  transit, transport
TrenitaliaAPI
Reverse engineering dell'API dell'app di Trenitalia
Stars: ✭ 32 (-40.74%)
Mutual labels:  transit, transport
ideas
How to make public transport more comfortable, more accessible, more transparent?
Stars: ✭ 35 (-35.19%)
Mutual labels:  transit, transport
open-bus
🚌 Analysing Israel's public transport data
Stars: ✭ 65 (+20.37%)
Mutual labels:  transit, transport
European Transport Modules
[DISCONTINUED in favour of public-transport-operators] Collection of european transport JavaScript modules.
Stars: ✭ 9 (-83.33%)
Mutual labels:  transit, transport
Vbb Modules
List of JavaScript modules for Berlin & Brandenburg public transport.
Stars: ✭ 47 (-12.96%)
Mutual labels:  transit, transport
Vbb Cli
A CLI for Berlin & Brandenburg public transport.
Stars: ✭ 70 (+29.63%)
Mutual labels:  transit, transport
vbb-hafas
A JavaScript client for Berlin & Brandenburg public transport HAFAS API.
Stars: ✭ 28 (-48.15%)
Mutual labels:  transit, transport
bvg-topological-map
BVG transport map as a nice SVG.
Stars: ✭ 15 (-72.22%)
Mutual labels:  transit, transport
matsim-sbb-extensions
matsim swiss rail
Stars: ✭ 23 (-57.41%)
Mutual labels:  transit, transport
Hafas Client
JavaScript client for HAFAS public transport APIs.
Stars: ✭ 125 (+131.48%)
Mutual labels:  transit, transport
vbb-rest
An HTTP API for Berlin & Brandenburg public transport.
Stars: ✭ 104 (+92.59%)
Mutual labels:  transit, transport
Tidytransit
R package for working with the General Transit Feed Specification (GTFS)
Stars: ✭ 84 (+55.56%)
Mutual labels:  transit, transport
transxchange2gtfs
tool to convert transxchange data into a GTFS feed
Stars: ✭ 26 (-51.85%)
Mutual labels:  transit, transport
Peering Manager
Peering sessions management tool
Stars: ✭ 189 (+250%)
Mutual labels:  transit
Next-Station-iOS
Source code of Next Station iOS app, available on App Store for downloading.
Stars: ✭ 15 (-72.22%)
Mutual labels:  transport

db-hafas

A client for the German Railways (DB). 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.

npm version ISC-licensed support me via GitHub Sponsors chat with me on Twitter

Installing

npm install db-hafas

API

Check the docs for hafas-client@6 as well as its DB-specific customisations.

Getting Started

import {createDbHafas} from 'db-hafas'

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

As an example, we will search for a route from Berlin Jungfernheide to München Hbf. To get the station IDs, use locations(query, [opt]).

// Berlin Jungfernheide to München Hbf
const {journeys} = await hafas.journeys('8011167', '8000261', {
	results: 1,
})
console.log(journeys[0])

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

[ {
	type: 'journey',
	legs: [ {
		tripId: '1|300793|27|80|27032019',
		origin: {
			type: 'stop',
			id: '8089100',
			name: 'Berlin Jungfernheide (S)',
			location: {
				type: 'location',
				id: '8089100',
				latitude: 52.530408,
				longitude: 13.299424
			},
			products: {
				nationalExpress: false,
				national: false,
				regionalExp: false,
				regional: true,
				suburban: true,
				bus: true,
				ferry: false,
				subway: true,
				tram: false,
				taxi: false
			},
			station: {
				type: 'station',
				id: '8011167',
				name: 'Berlin Jungfernheide',
				location: { /* … */ },
				products: { /* … */ }
			}
		},
		departure: '2019-03-27T14:10:00.000+01:00',
		departureDelay: 0,
		departurePlatform: '6',
		destination: {
			type: 'stop',
			id: '8089073',
			name: 'Berlin Südkreuz (S)',
			location: { /* … */ },
			products: { /* … */ },
			station: { /* … */ }
		},
		arrival: '2019-03-27T14:30:00.000+01:00',
		arrivalDelay: 0,
		arrivalPlatform: '12',
		direction: 'Berlin Südkreuz (S)',
		line: {
			type: 'line',
			id: 's-42',
			fahrtNr: '42133',
			name: 'S 42',
			public: true,
			mode: 'train',
			product: 'suburban',
			operator: {type: 'operator', id: 's-bahn-berlin', name: 'S-Bahn Berlin'}
		},
		cycle: {min: 300, max: 300, nr: 25}
	}, {
		origin: { /* … */ },
		departure: '2019-03-27T14:30:00.000+01:00',
		destination: { /* … */ },
		arrival: '2019-03-27T14:37:00.000+01:00',
		public: true,
		walking: true,
		distance: 622
	}, {
		tripId: '1|245684|0|80|27032019',
		origin: { /* … */ },
		departure: '2019-03-27T14:37:00.000+01:00',
		departureDelay: 0,
		departurePlatform: '3',
		destination: {
			type: 'stop',
			id: '8000261',
			name: 'München Hbf',
			location: { /* … */ },
			products: { /* … */ }
		},
		arrival: '2019-03-27T19:06:00.000+01:00',
		arrivalDelay: 0,
		arrivalPlatform: '18',
		direction: 'München Hbf'
		line: {
			type: 'line',
			id: 'ice-1601',
			fahrtNr: '1601',
			name: 'ICE 1601',
			public: true,
			mode: 'train',
			product: 'nationalExpress',
			operator: { /* … */ }
		},
	} ],
	refreshToken: '…',
	price: {amount: null, hint: 'No pricing information available.'}
} ]

Similar Projects

  • Fahrplan.js – "A JavaScript client for Deutsche Bahn's timetable API"
  • db-prices – Find the cheapest routes using the DB Sparpreise API.
  • db-stations – An offline list of all DB stations.

Also 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].