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

trias-client

v0.5.0

Published

Lean Node.js client for public transport TRIAS APIs.

Downloads

29

Readme

TRIAS Client

A lean Node.js client for TRIAS APIs. 🚀

This client aims to be an easy to use and lightweight implementation for the public transport TRIAS specification. It achieves that by providing only a small subset of the capabilities of TRIAS and utilizing the Friendly Public Transport Format.

trias-client currently implements TRIAS v1.2 and only supports following basic functionalities:

  • Searching for stops (either using a name or coordinates).
  • Fetching departures for a stop.
  • Reading current ticker news for a stop.
  • Navigating from stop to stop.

Usage

Please note that you will need an API endpoint and an API key or requestor reference key issued by a data provider. Check the providers list for open APIs.

Install the package:

npm install trias-client

Following script creates a client instance, searches for a station and fetches the departures for the first result. Please refer to the documentation for more information.

const trias = require("trias-client");

var client = trias.getClient({
    url: "place the url of the TRIAS API here",
    requestorRef: "place your requestor ref here"
});

var stopsResult = await client.getStops({
    name: "bismarckplatz"
});

var departuresResult = await client.getDepartures({
    id: stopsResult.stops[0].id
});

There's also an example script available that demonstrates how to use trias-client.

What is TRIAS?

TRIAS stands for "Travellor Realtime Information and Advisory Standard", has been developed in scope of the research and standardisation project for public transport "IP-KOM-ÖV" and was then introduced in 2014 as a standardized specification by the VDV (Verband Deutscher Verkehrsunternehmen). TRIAS offers a wide-range list of functionalities, including station / location search, realtime departures, navigation, ticket price calculation, malfunction reportings, and so on. Here is a list of all public transport providers that provide a TRIAS API.

Why TRIAS?

Compared to HAFAS, TRIAS isn't that widely distributed. But it's a step in the right direction as it allows for some kind of standardization in the jungle of Public Transport APIs. Unfortunately, many of the data providers still build their own proprietary APIs.

You might wonder why this even matters if you can just continue to use the existing HAFAS interfaces. The biggest difference is that these HAFAS interfaces are not supposed to be used by the public and public transport providers might even prohibit to use them (you can read more about that here). So if you want to develop and publish a project that uses public transport data, you might want to have some kind of agreement with the data provider, that reduces operational and legal risk for both you and the provider.

And this is where TRIAS becomes relevant, as the APIs built on it are public (not open, as they still require authentication, but public). And while some providers are a bit more strict regarding the use and display of the data, in general all of the APIs have fair terms of use and come with realistic usage quotas.

Related resources

trias-client was originally developed in scope of Abfahrt, a public transport companion that integrates multiple ÖPNV providers in just one app. You can take a look over there to see this client in action.

Dou you want to develop your own TRIAS client? Here are some resources:

Made with :two_hearts: in Heidelberg.