oebb-hafas
Client for the Austrian Railways (ÖBB) HAFAS API. It acts as a consistent and straightforward interface on top of a verbose API.
This project is actually a thin wrapper around hafas-client
. Its docs document the API in general.

Installing
npm install oebb-hafas
API
Check the docs for hafas-client
as well as the ÖBB-specific customisations.
Getting Started
const hafas = require('oebb-hafas')
As an example, we will search for a route from Wien Westbahnhof to Salzburg Hbf. To get the station ids, use locations(query, [opt])
.
client.journeys('1291501', '8100002')
.then((journeys) => console.log(journeys[0]))
.catch(console.error)
The output will be a journey
object in the Friendly Public Transport Format 1.0.1
format:
[ {
legs: [
{
origin: {
type: "station",
id: "8100003",
name: "Wien Westbahnhof",
location: {
type: "location",
latitude: 48.196366,
longitude: 16.337328
},
products: {
nationalExp: false,
national: false,
interregional: true,
regional: true,
suburban: true,
bus: false,
ferry: false,
subway: false,
tram: false,
unknown: false,
onCall: false
}
},
destination: {
type: "station",
id: "8100002",
name: "Salzburg Hbf",
location: {
type: "location",
latitude: 47.812851,
longitude: 13.045604
},
products: {
nationalExp: true,
national: true,
interregional: true,
regional: true,
suburban: true,
bus: false,
ferry: false,
subway: false,
tram: false,
unknown: false,
onCall: false
}
},
departure: "2018-01-07T17:43:00.000+01:00",
arrival: "2018-01-07T20:08:00.000+01:00",
id: "1|349663|11|181|7012018",
line: {
type: "line",
id: "924",
name: "WB 924",
public: true,
class: 4096,
productCode: 12,
operator: {
type: "operator",
id: "westbahn-management-gmbh",
name: "WESTbahn Management GmbH"
},
product: "interregional",
mode: "train"
},
direction: "Salzburg Hbf",
departurePlatform: "6",
arrivalPlatform: "2A-C"
}
],
origin: {
type: "station",
id: "8100003",
name: "Wien Westbahnhof",
location: {
type: "location",
latitude: 48.196366,
longitude: 16.337328
},
products: {
nationalExp: false,
national: false,
interregional: true,
regional: true,
suburban: true,
bus: false,
ferry: false,
subway: false,
tram: false,
unknown: false,
onCall: false
}
},
destination: {
type: "station",
id: "8100002",
name: "Salzburg Hbf",
location: {
type: "location",
latitude: 47.812851,
longitude: 13.045604
},
products: {
nationalExp: true,
national: true,
interregional: true,
regional: true,
suburban: true,
bus: false,
ferry: false,
subway: false,
tram: false,
unknown: false,
onCall: false
}
},
departure: "2018-01-07T17:43:00.000+01:00",
arrival: "2018-01-07T20:08:00.000+01:00"
} ]
Similar Projects
-
- oebb – Find ticket prices for ÖBB journeys.
- db-hafas – Client for the German Railways (DB).
- vbb-hafas – Client for the Berlin & Brandenburg public transport service (VBB).
Contributing
If you found a bug, want to propose a feature or feel the urge to complain about your life, feel free to visit the issues page.