JavaScript client for the deinbus coach travel API. Complies with the friendly public transport format (FPTF 0.0
). Inofficial, using an endpoint by Deinbus. Ask them for permission before using this module in production.
npm install --save deinbus
This package contains data in the Friendly Public Transport Format.
Using deinbus.stations
, you can get all stations operated bei Deinbus.
const stations = require('deinbus').stations
stations().then(console.log)
Returns a Promise that will resolve in an array of station
s in the Friendly Public Transport Format which looks as follows:
[
{
type: 'station',
id: 'BEZ',
name: 'Berlin (ZOB)',
destinations: [
'ASL',
'ERF',
'FRA'
// …
]
}
// …
]
Using deinbus.journeys
, you can get directions and prices for routes from A to B.
const journeys = require('deinbus').journeys
journeys(origin, destination, date = Date.now(), opt = defaults)
const BerlinZOB = 'BEZ'
const Leipzig = 'LPZ'
const date = new Date() // ignores specific time, searches the entire day (based on Europe/Berlin timezone)
journeys(BerlinZOB, Leipzig, date)
.then(console.log)
.catch(console.error)
Returns a Promise that will resolve with an array of journey
s in the Friendly Public Transport Format which looks as follows.
Note that the legs are not fully spec-compatible, as the schedule
is missing and for API-specific reasons, the journey always contains exactly one leg (see also: transfers
key).
[
{
"type": "journey",
"id": "BEZ_LPZ_2017-07-13_0715",
"legs": [
{
"origin": "BEZ",
"destination": "BEZ",
"departure": "2017-07-13T05:15:00.000Z", // JS Date() object
"arrival": "2017-07-13T07:25:00.000Z" // JS Date() object
}
],
"transfers": 0,
"transferInfo": "",
"price": {
"amount": 8.5,
"currency": "EUR",
"bookable": true,
"bookableUntil": "2017-07-13T05:00:00.000Z", // JS Date() object
"soldOut": false,
"tickets": [
{
"price": {
"amount": 8.5,
"currency": "EUR"
},
"child": false,
"description": null
}
// …
]
},
"insufficientCapacity": false,
"minChildBirthdate": "2002-07-13T22:00:00.000Z", // JS Date() object
"maxUnattendedChildBirthdate": "2011-07-12T22:00:00.000Z" // JS Date() object
}
// …
]
defaults
, partially overridden by the opt
parameter, looks like this:
const defaults = {
passengers: {
adults: 1,
children: 0
}
}
- FPTF - "Friendly public transport format"
- FPTF-modules - modules that also use FPTF
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.