public-transport / transport.rest

Information about the *.transport.rest APIs.

Home Page:https://transport.rest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

västtrafik.transport.rest

linusromland opened this issue · comments

Would love for you to add Västrafik to your API.

Do you have a URL where I can have a look at the API?

Unfortunately, we can't use this API right away.

There are two flavors of HAFAS APIs:

  • mgate.exe (a.k.a. "mobile") APIs serve mostly HaCon's (the HAFAS developer) proprietary apps, mainly the transport agencies' official mobile apps. They usually have no or static authentication.
  • rest.exe (a.k.a. REST) APIs are intended to serve third-party developers like us. They usually have user-specific or even app-specific authentication.

Both flavors have very similar semantics and naming schemes, but they differ significantly in their request/response format; This why covering both with a single client requires either quite a bit of duplicate code or quite complex abstraction layers. The work to adapt hafas-client to rest.exe APIs is ongoing, check out public-transport/hafas-client#134 for details; A previous state of this PR has also been pulled out into https://github.com/public-transport/hafas-rest-client.

This why I see two obstacles to getting a v5.vasttrafik.transport.rest API running:

  • We should clarify if their terms and conditions actually allow wrapping their individually authenticated into an anonymous, unauthenticated API. I don't understand Swedish, so I can't tell.
  • Reseplaneraren (https://api.vasttrafik.se/bin/rest.exe/v2/…) is a rest.exe-style API. I assume that hafas-client's rest-exe PR still needs some minor adjustments to use it as a (basic!) backend for the API.

A minor obstacle: If the API is rate-limited (I'm not sure, but I assume that it is), on v5.vasttrafik.transport.rest, we should set a rate limit low enough, so that people don't accidentally "use up" all upstream requests and it is effectively not publicly available anymore.

If you would like to contribute, clarifying the legal/formal part would be awesome! You could help me by Google-Translate-/deepl-translating the relevant sections and double-checking that the translation sounds equivalent in a legal sense; I don't expect from you to give legal advice of course, but I assume that you can give your personal judgement.

Once everything is prepared, setting up the actual API server should be straightforward.

Now that I'm thinking about it, it would be a lot easier if we add the (static) authentication used by Västtrafik's HAFAS mobile app, which very likely uses the mgate.exe API, to hafas-client. If you would like contribute this, please follow hafas-client's instructions (please give feedback if that guide is not helpful).