public-transport / ideas

How to make public transport more comfortable, more accessible, more transparent?
Creative Commons Attribution Share Alike 4.0 International
37 stars 0 forks source link

Introduce TRIAS resources #18

Open andaryjo opened 3 years ago

andaryjo commented 3 years ago

While most of the resources here focus on HAFAS, I think it would be a good idea to also consider creating and sharing resources on TRIAS, wich is a relatively new interface specification pushed by many public transport companies.

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, etc.

Here's a list of public transport providers that provide a TRIAS interface (that I know of). Most of them only implemented the more basic functionalities of the TRIAS specification:

Currently, there aren't a lot of helpful resources on TRIAS. Most providers only publish a few implementation examples and refer to the documentation: VDV 431-2 EKAP-Schnittstellenbeschreibung

But why?

Compared to HAFAS, TRIAS obviously isn't that widely distributed. But I think 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. At least in my opinion, 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 it. 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 data 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 at least in my experience, some providers are a bit more strict regarding the use and display of the data, but in general all of the APIs have fair terms of use and come with realistic request quotas.

I wouldn't want to make any assumptions on what specification is superior from a technical perspective, as I don't have that much experience with HAFAS. TRIAS is XML-based (urgh) and comes with a quite high request payload, but it's easy to understand and well documented.

So what to do?

Firstly, I'd just wanted to raise awareness that there actually is at least a bit of public API standardization out there. And then I think it would be interesting to provide learning resources and client libraries to achieve better developer enablement and maybe drive the adoption of TRIAS.

After a quick search I only found a few public resources and both of them seem to be somewhat propriertary:

As I've been using TRIAS for a long time now and I have a working multi-provider TRIAS client in place, I'd be interested in trying to develop a generic and easy to use JS TRIAS client library which also utilizes the Friendly Public Transport Format you guys already established.

derhuerst commented 3 years ago

[…] I'd be interested in trying to develop a generic and easy to use JS TRIAS client library which also utilizes the Friendly Public Transport Format you guys already established.

That would be amazing! Just open a draft PR somewhere, tag me, and we can collaborate.

kiliankoe commented 3 years ago

FWIW, the Verkehrsverbund Oberelbe also provides a TRIAS interface at http://efa.vvo-online.de:8080/std3/trias.

Also, if you were referring to the (unfortunately very unfinished) Swift client as being proprietary because it was missing a license, that was just an oversight on my part. It's there now 😊

derhuerst commented 3 years ago

@juliuste might also be interested in writing a TRIAS client.

andaryjo commented 3 years ago

@kiliankoe Thanks for the info, I updated my post. ☺️

iLazlow commented 3 years ago

TRIAS also supports JSON output and can be requested with url parameters. If anyone doesn't want to use XML.

derhuerst commented 3 years ago

TRIAS also supports JSON output and can be requested with url parameters. If anyone doesn't want to use XML.

Thanks for the hint! What is the parameter for that?

andaryjo commented 3 years ago

@iLazlow The TRIAS documentation does not mention JSON at all. Is this maybe something specific to a single provider?

iLazlow commented 3 years ago

For DM Request as example you can use the parameter outputFormat=JSON e.g: {APIBase}/XML_DM_REQUEST?outputFormat=JSON&coordOutputFormat=WGS84[dd.ddddd]&mode=direct&name_dm=de:8212:6&type_dm=stop

Tested these on multiple providers and there are maybe one or two which block their requests to xml output. Sometimes "XML_DM_REQUEST" has to be renamed to "XSLT_DM_REQUEST". This works also on all other endpoints like "XSLT_TRIP_REQUEST2" or "XML_STOPSEQCOORD_REQUEST".

Here a link to the "open" KVV Api: https://projekte.kvv-efa.de/sl3-alone/XML_DM_REQUEST?outputFormat=JSON&coordOutputFormat=WGS84[dd.ddddd]&mode=direct&name_dm=de:8212:6&type_dm=stop

Tested the json output so far successfully on these providers KVV VRN Bwegt VVS VGN GVH (efa.de) Even the swiss TRIAS supports json (but their stops are not in GID format)

andaryjo commented 3 years ago

For DM Request as example you can use the parameter outputFormat=JSON e.g: {APIBase}/XML_DM_REQUEST?outputFormat=JSON&coordOutputFormat=WGS84[dd.ddddd]&mode=direct&name_dm=de:8212:6&type_dm=stop

Unfortunately that's not TRIAS. While I've seen many providers build their TRIAS interface on top of their internal EFA controllers, it's not the same. You can take a look at the TRIAS specification here.

iLazlow commented 3 years ago

For DM Request as example you can use the parameter outputFormat=JSON

e.g: {APIBase}/XML_DM_REQUEST?outputFormat=JSON&coordOutputFormat=WGS84[dd.ddddd]&mode=direct&name_dm=de:8212:6&type_dm=stop

Unfortunately that's not TRIAS. While I've seen many providers build their TRIAS interface on top of their internal EFA controllers, it's not the same. You can take a look at the TRIAS specification here.

OH good to know its my mistake then. Worked with the same request pages and even the same parameters so I thought it's TRIAS 😅

derhuerst commented 1 year ago

Just to make them more discoverable, here are the two open source TRIAS clients that I'm aware of: