1.2.0 • Published 6 years ago

mvgapi v1.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Simple MVG API

Installation

npm install --save mvgapi

Usage

Search for stations

const MVGAPI = require('mvgapi');

MVGAPI.searchForLocations('Uni').then(locations => {
    locations.forEach(loc => {
        console.log(`Station ${loc.name} with id ${loc.id} in ${loc.place} offers ${loc.products.join(' and ')}`);
    });
}).catch(err => {
    console.log(`Ups, an error occured: \n ${err}`);
});

locations is an array of IMVGStation objects

id: number,
name: string,
place: string,
products: string[]

Routes

MVGAPI.route(70, 438).then(routes => {
    routes.forEach((route, idx) => {
        console.log(`Route ${1} departure ${new Date(route.departure)} arrives at ${new Date(route.arrival)} using
            ${route.connectionPartList.map(part => `${part.product !== undefined ? (part.product.toUpperCase() + part.label) : 'Footway'}`).join(' and ')}`);
    });
}).catch(err => {
    console.log(`Ups, an error occured: \n ${err}`);
});

routes is an array of IMVGRoute objects

arrival: number,
departure: number,
ringFrom: number,
ringTo: number,
connectionPartList: IMVGRoutePart[]

where IMVGRoutePart provides the following information

arrival: number,
arrivalPlatform: string,
departure: number,
departurePlatform: string,
destination: string,
from: IMVGStation,
to: IMVGStation,
label: string,
product: string,
sev: boolean,
connectionPartType: string

Departures

MVGAPI.departures(70).then(departures => {
    departures.forEach(departure => {
        console.log(`${departure.product.toUpperCase()}${departure.label} at ${new Date(departure.departureTime)} with direction ${departure.destination}`);
    });
}).catch(err => {
    console.log(`Ups, an error occured: \n ${err}`);
});

departures is an array of IMVGDeparture objects

departureId: number,
departureTime: number,
destination: string,
label: string,
live: boolean,
product: string,
sev: boolean
1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago