This package has been deprecated

Author message:

WARNING: This package is unmaintained and might be broken. If you would like to maintain it, please contact mail@juliustens.eu

deinbus

0.0.0 • Public • Published

deinbus

JavaScript client for the deinbus coach travel API. Complies with the friendly public transport format (FPTF 0.0)

npm version Build Status dependency status dev dependency status license chat on gitter

Installation

npm install --save deinbus

Usage

This package contains data in the Friendly Public Transport Format.

stations

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 stations in the Friendly Public Transport Format which looks as follows:

[
    {
        type: 'station',
        id: 'BEZ',
        name: 'Berlin (ZOB)',
        destinations: [
            'ASL',
            'ERF',
            'FRA'
            // …
        ]
    }
    // …
]

journeys

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 journeys 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
    }
}

See also

  • FPTF - "Friendly public transport format"
  • FPTF-modules - modules that also use FPTF

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.

Readme

Keywords

none

Package Sidebar

Install

npm i deinbus

Weekly Downloads

2

Version

0.0.0

License

MIT

Last publish

Collaborators

  • juliuste