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

wiener-linien-api

v0.6.0

Published

Typescript wrapper for Wiener Linien Realtime Data API

Downloads

7

Readme

Tests

Wiener Linien API

Wiener Linien provide a couple of different APIs du to the Open Data initiative of Vienna.

The goal of this library is to wrap all of those APIs in an easy to use way. Currently the following APIs are supported:

Access keys are not required, but their fair use policy states to keep requests at least 15 seconds apart. You will have to handle this, it is not done by the API Wrapper.

Installation

Install with the packagemanager of your choice, package is available on npm.

yarn add wiener-linien-api

Usage

All available API endpoints are being wrapped by this library.

Realtime Data

This API relies on the knowledge of the stopId or multiple stop IDs for that matter or the DIVA.

Querying data by DIVA is the prefered method since it will return data for all stops withing this DIVA.

For example: Praterstern has 17 stopIds related to it which can all be queryied by just one DIVA.

The most convenient way I could find is this CSV file containing stops with their stopId and DIVA numbers.

getMonitor(diva, params)

Get live departure data for one or more stations

Parameters:

  • diva number | Array<number> - DIVA(s) you are interested id
  • params object - Optional additional parameters to filter the results
{
  activateTrafficInfo?: string | Array<string>;
  aArea?: BooleanNumber;
}

Examples:

import { RealtimeData } from "wiener-linien-api";

const client = new RealtimeData();

let monitor = client.getMonintor(60201095);
monitor = await client.getMonintor([60201040, 60201095]);
monitor await client.getMonitor(60201040, {
  activateTrafficInfo: [
    "fahrtreppeninfo",
    "informationen",
    "aufzugsinfo",
  ],
});

getMonitorByStopId(stopId, params)

Get live departure data for one or more stations

Parameters:

  • stationId number | Array<number> - stationID(s) you are interested id
  • params object - Optional additional parameters to filter the results
{
  activateTrafficInfo?: string | Array<string>;
  aArea?: BooleanNumber;
}

Examples:

import { RealtimeData } from "wiener-linien-api";

const client = new RealtimeData();

let monitor = await client.getMonintorByStopId(1095);
monitor = await client.getMonintorByStopId([1095, 1096]);

getNewsList(params)

Get a list of news

Parameters:

  • params object - Optional additional parameters to filter the results
{
  relatedLine?: string | Array<string>,
  relatedStop?: number | Array<number>,
  name?: string | Array<string>,
}

Examples:

import { RealtimeData } from "wiener-linien-api";

const client = new RealtimeData();

const list = await client.getNewsList();

getNews(name)

Show news by their name

Parameters:

  • name string | Array<string> - The name of the news you are interested in

Examples:

import { RealtimeData } from "wiener-linien-api";

const client = new RealtimeData();

let list = await client.getNews("news_1");
list = await client.getNews(["news_1", "news_2"]);

getTrafficInfoList(params)

Get a list of traffic info items

Parameters:

  • params object - Optional additional parameters to filter the results
{
  relatedLine?: string | Array<string>,
  relatedStop?: number | Array<number>,
  name?: string | Array<string>,
}

Examples:

import { RealtimeData } from "wiener-linien-api";

const client = new RealtimeData();

let list = await client.getTrafficInfoList();
list = await client.getTrafficInfoList({
  relatedLine: ["U1", "U3"],
});

getTrafficInfo(name)

Show traffic info items by their name

Parameters:

-name string | Array<string> - The name of the traffic info you are interested in

Examples:

import { RealtimeData } from "wiener-linien-api";

const client = new RealtimeData();

let result = await client.getTrafficInfo("name_1");
result = await client.getTrafficInfo(["name_1", "name_2"]);

Interfaces

There are interfaces for all the related data. I put them together from the official documentation and the actual data being returned.

Not everything the API is returning, is actually documented, so the interfaces might not be 100% up to date. I would not rely on the undocumented fields as they might disappear anytime.

Please feel free to share your experiences and commit PRs where you see fit, especially for those undocumented cases.

Testing

Tests are in place, there are timeouts between each tests to comply with the APIs fair use policy, so they take some time to finish running.

Tests are a bit naive and we are only testing for valid responses, not checking against any interface since the actually returned data obviously changed during the course of the day.

With API wrappers I am personally not a fan to test against mocks, since obviously they would pass any time.

Resources:

  • https://www.data.gv.at/katalog/dataset/wiener-linien-echtzeitdaten-via-datendrehscheibe-wien
  • https://till.mabe.at/rbl/