Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
db-hafas
Advanced tools
Readme
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 install db-hafas
Check the docs for hafas-client@6
as well as its DB-specific customisations.
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.'}
} ]
Also check hafas-client
's related projects.
If you have a question, found a bug or want to propose a feature, have a look at the issues page.
FAQs
JavaScript client for the DB HAFAS API.
The npm package db-hafas receives a total of 24 weekly downloads. As such, db-hafas popularity was classified as not popular.
We found that db-hafas demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.