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

mvg-node

v1.3.0

Published

NodeJS client for the Munich Public Transport System

Downloads

6

Readme

mvg-node

NodeJS client for the Munich Public Transport System

Install

$ npm install mvg-node

Usage

Getting departures

const mvg = require('mvg-node');

(async () => {
  let home = await mvg.getStation('Feldbergstr')

  let departures = await mvg.getDepartures(home);
  console.log(departures);
})();
[ { departureTime: 1500923983000,
    product: 'b',
    label: '194',
    destination: 'Trudering Bf.',
    live: true,
    lineBackgroundColor: '#0d5c70',
    departureId: 325930522,
    sev: false,
    time: 2017-07-24T19:19:43.000Z },
  { departureTime: 1500924014000,
    product: 'b',
    label: '192',
    destination: 'Neuperlach Zentrum',
    live: true,
    lineBackgroundColor: '#0d5c70',
    departureId: -120781808,
    sev: false,
    time: 2017-07-24T19:20:14.000Z },
    ... ]

API

async getStation(input) -> object

Fetch information about a specific station

| Parameter | Description | | :-------- | :---------- | | input | Either a Number (station ID) or a String (station name) | | Returns | An Object containing information about a specific station. This object can be passed to the other functions |

async getStations(input) -> array

Search stations by name

| Parameter | Description | | :-------- | :---------- | | name | The station name to search for | | Returns | An Array of object representing stations |

async allStations() -> array

Fetch all stations

async getDepartures(station) -> array

Load a specific station's upcoming departures

| Parameter | Description | | :-------- | :---------- | | station | Either a station object or a station id | | Returns | An Array of upcoming departures from that station |

async getRoute(start, destination, options) -> array

Get routes between two stations

| Parameter | Description | | :-------- | :---------- | | start | The route's starting point (either a station object, or a station id (Number) or a station name (String) | | destination | The route's destination (either a station object, or a station id (Number) or a station name (String) | | options | Either a date object (the route's starting time) or some more options (start, arrival, maxTravelTimeFootwayToStation, maxTravelTimeFootwayToDestination) | | Returns | An Array of routes between the two stations |

CLI

$ npm install --global mvg-node
$ mvg-node --help

  NodeJS client for the Munich Public Transport System

  Usage
    $ mvg-node [input] <options>

  Commands
     station      Get information about a specific station
     departures   Get upcoming departures for a specific station.

  Options
     --all        By default, this shows the next 10 departures. Pass `--all` to get all upcoming departures


  Examples
    $ mvg-node station 953

    $ mvg-node departures 'Hauptbahnhof'

Get departures

$ mvg-node departures 'Hauptbahnhof'
Upcoming departures for 'Hauptbahnhof':
┌─────────┬────────────────────────────────────────┐
│   ⏳    │                                        │
├─────────┼────────────────────────────────────────┤
│ 1 min   │ S8 Herrsching                          │
├─────────┼────────────────────────────────────────┤
│ 1 min   │ U5 Neuperlach Süd                      │
├─────────┼────────────────────────────────────────┤
│ 1 min   │ U1 Olympia - Einkaufszentrum           │
├─────────┼────────────────────────────────────────┤
│ 1 min   │ U1 Mangfallplatz                       │
├─────────┼────────────────────────────────────────┤
│ 2 min   │ U5 Laimer Platz                        │
├─────────┼────────────────────────────────────────┤
│ 2 min   │ Bus 58 Silberhornstraße                │
├─────────┼────────────────────────────────────────┤
│ 3 min   │ S7 Höhenkirchen-Siegertsbrunn          │
├─────────┼────────────────────────────────────────┤
│ 4 min   │ U2 Feldmoching                         │
├─────────┼────────────────────────────────────────┤
│ 4 min   │ Tram 16 Romanplatz                     │
├─────────┼────────────────────────────────────────┤
│ 4 min   │ U2 Messestadt Ost                      │
└─────────┴────────────────────────────────────────┘

License

MIT © Lukas Kollmer

mvg-node was inspired by leftshift/python_mvg_api