Socket
Socket
Sign inDemoInstall

eurolines-de

Package Overview
Dependencies
64
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eurolines-de

Client for the eurolines.de coach travel API.


Version published
Weekly downloads
1
decreased by-92.31%
Maintainers
1
Install size
15.6 MB
Created
Weekly downloads
 

Readme

Source

eurolines-de

JavaScript client for the eurolines.de coach travel API. Complies with the friendly public transport format. In progess…

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

Installation

npm install --save eurolines-de

Usage

This package contains data in the Friendly Public Transport Format.

stations([query], [opt])

Get all stations operated bei eurolines.

const stations = require('eurolines-de').stations

stations().then(console.log) // all stations

stations('Berl') // search for stations
stations({origin: 'Berlin'}) // search for stations reachable by the station with id 'Berlin'
stations('Frankf', {origin: 'Berlin'}) // search in stations reachable from Berlin

Searches stations based on query. If no query parameter is found, returns all stations (still regarding opt instead).

The defaults for opt look like this:

{
    language: 'de',
    origin: null // set to specific station id to filter for stations reachable by there
}

Returns a Promise that will resolve in an array of stations in the Friendly Public Transport Format which looks as follows:

[
    {
        type: 'station',
        id: 'Aachen',
        name: 'Aachen (DE)'
    },
    {
        type: 'station',
        id: 'Aalborg',
        name: 'Aalborg (DK)'
    },
    {
        type: 'station',
        id: 'Aalen',
        name: 'Aalen (DE)'
    }
    // …
]

journeys(origin, destination, date = Date.now(), opt = {})

Get directions and prices for routes from A to B. scraped 😕

const journeys = require('eurolines-de').journeys

journeys('Berlin', 'Paris', new Date(), {passengers: 1})
.then(console.log)
.catch(console.error)

defaults, partially overridden by the opt parameter, looks like this:

const defaults = {
    passengers: 1
}

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 in legs, all dates are Date() objects instead of ISO strings and due to API-specific reasons, there will always only be one leg and the additional transfers key instead.

[
    {
        origin: 'Berlin',
        destination: 'Paris',
        type: 'journey',
        id: 'BerlinParisWed Jul 19 2017 19:30:00 GMT+0200 (CEST)Thu Jul 20 2017 09:45:00 GMT+0200 (CEST)0',
        departure: '2017-07-19T17:30:00.000Z', // JS Date() object
        arrival: '2017-07-20T07:45:00.000Z', // JS Date() object
        transfers: 0,
        price: {
            currency: 'EUR',
            amount: 83,
            fares: [
                {
                    type: 'fare',
                    model: 'normal',
                    price: {
                        currency: 'EUR',
                        amount: 83
                    }
                }
            ]
        },
        legs: [
            {
                origin: 'Berlin',
                destination: 'Paris',
                departure: '2017-07-19T17:30:00.000Z', // JS Date() object
                arrival: '2017-07-20T07:45:00.000Z' // JS Date() object
            }
        ]
    }
    // …
]

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.

Keywords

FAQs

Last updated on 04 Jul 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc