npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flix

v5.0.2

Published

JavaScript client for the FlixBus (Meinfernbus) / FlixTrain API.

Downloads

60

Readme

flix

JavaScript client for the FlixBus (Meinfernbus) / FlixTrain API. Inofficial, using endpoints by FlixMobility. Ask them for permission before using this module in production.

This module conforms to the FPTI-JS 0.3.2 standard for JavaScript public transportation modules.

npm version Build Status Greenkeeper badge license fpti-js version chat on gitter

Installation

npm install flix

Usage

const flix = require('flix')

The flix module conforms to the FPTI-JS 0.3.2 standard for JavaScript public transportation modules and exposes the following methods:

Method | Feature description | FPTI-JS 0.3.2 -------|---------------------|-------------------------------------------------------------------- stations.all([opt]) | All stations of the Flix network, such as Berlin central bus station or Frankfurt Hbf | ✅ yes regions.all([opt]) | All regions (cities) of the Flix network, such as Berlin or Frankfurt | ✅ yes journeys(origin, destination, [opt]) | Journeys between stations or regions | ✅ yes


stations.all([opt])

Get all stations of the Flix network, such as Berlin central bus station or Frankfurt Hbf. See this method in the FPTI-JS 0.3.2 spec.

Supported Options

Attribute | Description | FPTI-spec | Value type | Default ----------|-------------|------------|------------|-------- apiKey | Custom Flix API key | ❌ | String | default api key

Example

const flix = require('flix')
const stationStream = flix.stations.all()

stationStream.on('data', item => {
    // item is an FPTF station object
    console.log(item)
})
{
    type: "station",
    id: "1",
    name: "Berlin central bus station",
    location: {
        type: "location",
        longitude: 13.279399,
        latitude: 52.507171,
        address: "Masurenallee 4-6, 14057 Berlin, Germany",
        country: {
            name: "Germany",
            code: "DE"
        },
        zip: "14057",
        street: "Masurenallee 4-6"
    },
    slug: "berlin-zob",
    aliases: [],
    regions: [
        "88"
    ],
    connections: [
        2,
        3,
        4,
        5,
        8,
        9
        // …
    ],
    importance: 100
}

regions.all([opt])

Get all regions of the Flix network, such as Berlin or Frankfurt. See this method in the FPTI-JS 0.3.2 spec.

Supported Options

Attribute | Description | FPTI-spec | Value type | Default ----------|-------------|------------|------------|-------- apiKey | Custom Flix API key | ❌ | String | default api key

Example

const flix = require('flix')
const regionStream = flix.regions.all()

regionStream.on('data', item => {
    // item is an FPTF region object
    console.log(item)
})
{
    type: "region",
    id: "88",
    name: "Berlin",
    location: {
        type: "location",
        longitude: 13.404616,
        latitude: 52.486081,
        country: {
            name: "Germany",
            code: "DE"
        }
    },
    class: "A",
    stations: [
        "1",
        "20688",
        "1224",
        "20678",
        "481"
        // …
    ],
    connections: [
        89,
        90,
        91,
        92,
        93,
        94,
        96,
        97,
        98
        // …
    ],
    slug: "berlin"
}

journeys(origin, destination, [opt])

Find journeys between stations or regions. See this method in the FPTI-JS 0.3.2 spec. Note that origin and destination must have the same type (so either both region or both station).

Supported Options

Attribute | Description | FPTI-spec | Value type | Default ----------|-------------|------------|------------|-------- when | Journey date, synonym to departureAfter | ✅ | Date | new Date() departureAfter | List journeys with a departure (first leg) after this date | ✅ | Date | new Date() results | Max. number of results returned | ✅ | Number | null interval | Results for how many minutes after when/departureAfter | ✅ | Number | null transfers | Max. number of transfers | ✅ | Number | null currency | Currency for journey.price | ✅ | ISO 4217 code | EUR language | Language of the results | ❌ | ISO 639-1 code | en adults | Number of traveling adults | ❌ | Number | 1 children | Number of traveling children | ❌ | Number | 0 bicycles | Number of traveling bicycles | ❌ | Number | 0 apiKey | Custom Flix API key | ❌ | String | default api key

Note that, unless opt.interval is specified, the module will return journeys that start after when/departureAfter, but before the beginning of the following calendar day.

Example

// journeys between stations
const berlinZOB = '1' // station id
const hamburgCentral = { // FPTF station
	type: 'station',
	id: '36'
	// …
}
flix.journeys(berlinZOB, hamburgCentral, { when: new Date('2019-06-27T05:00:00+0200'), currency: 'PLN' }).then(…)

// journeys between regions
const berlin = { // FPTF region
    type: 'region',
    id: '88'
    // …
}
const hamburg = { // FPTF region
	type: 'region',
	id: '118'
	// …
}
flix.journeys(berlin, hamburg, { when: new Date('2019-06-27T05:00:00+0200'), transfers: 0 }).then(…)
{
    type: "journey",
    id: "direct-80979121-1-36",
    legs: [
        {
            origin: {
                type: "station",
                id: "1",
                name: "Berlin central bus station",
                importance: 100
            },
            destination: {
                type: "station",
                id: "36",
                name: "Hamburg ZOB",
                importance: 100
            },
            departure: "2019-06-27T06:45:00+02:00",
            arrival: "2019-06-27T10:00:00+02:00",
            operator: {
                type: "operator",
                id: "mfb",
                name: "FlixBus DACH GmbH",
                url: "http://flixbus.de",
                address: "Karl-Liebknecht-Straße 33, D-10178 Berlin"
            },
            mode: "bus",
            public: true
        }
    ],
    status: "available",
    borders: false,
    info: {
        title: null,
        hint: null,
        message: null,
        warnings: []
    },
    price: {
        amount: 9.99,
        currency: "EUR",
        discounts: null,
        saleRestriction: false,
        available: true,
        url: "https://shop.global.flixbus.com/s?departureCity=88&arrivalCity=118&departureStation=1&arrivalStation=36&rideDate=27.06.2019&currency=EUR&adult=1&children=0&bike_slot=0"
    }
}

Similar Projects

  • search-flix-locations - Search for FlixBus (Meinfernbus) / FlixTrain cities & stations.
  • db-flix-cities – Get all DB stations located in the same city as the given FlixBus / FlixTrain location, and vice versa.
  • db-hafas - JavaScript client for the DB Hafas API.
  • db-stations - A list of DB stations.

Contributing

If you found a bug or want to propose a feature, feel free to visit the issues page.