Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API gone? #19

Open
harbaum opened this issue May 4, 2022 · 6 comments
Open

API gone? #19

harbaum opened this issue May 4, 2022 · 6 comments

Comments

@harbaum
Copy link

harbaum commented May 4, 2022

It seems the KVV API this project makes use of is gone. But since a similar service still exists there may be a new API ...

$ python -m kvvliveapi search Pionierstraße
Error: 404 Client Error: 404 for url: https://live.kvv.de/webapp/stops/byname/Pionierstra%C3%9Fe?key=377d840e54b59adbe53608ba1aad70e8
@harbaum
Copy link
Author

harbaum commented May 4, 2022

There seems to be a new API. A search request for the station name Pionierstraße works like this:
https://www.kvv.de/tunnelEfaDirect.php?action=XSLT_STOPFINDER_REQUEST&coordOutputFormat=WGS84[dd.ddddd]&name_sf=pionierstraße&outputFormat=JSON&type_sf=any

Googling for XSLT_STOPFINDER_REQUEST returns links like this one.

@Nervengift
Copy link
Owner

oof, that looks like a bigger rewrite is needed :(
I'll gladly take contributions since I no longer live in Karlsruhe. Might still have a look at it if I find the time.

@harbaum
Copy link
Author

harbaum commented May 5, 2022

There seem to be various endpoints to access KVV information related to this API. Unfortunately some (incl. tunnelfadirect) return HTML even if JSON is requested in some cases. But the aforementioned request for pionierstraße will return stateless "7000238" which in turn can be used like this to get the next ten departures from that station in JSON format:

https://projekte.kvv-efa.de/sl3-alone/XSLT_DM_REQUEST?outputFormat=JSON&coordOutputFormat=WGS84[dd.ddddd]&depType=stopEvents&locationServerActive=1&mode=direct&name_dm=7000238&type_dm=stop&useOnlyStops=1&useRealtime=1&limit=10

The URL doesn't sound "stable" and i'd prefer to use something that sounds more promising to last a little longer ...

Also the returned JSON contains all kinds of unwanted stuff which is a burden for my little microcontroller. And finally I haven't figured out yet to specify a certain track in the request so I can e.g. request only inbound trains. I could filter them out later but that won't allow me to predict the number of departures to be displayed.

So I'd like to figure out:

  • a stable endpoint to deliver JSON info
  • how to reduce unwanted content from the reply, and
  • how to request only certain tracks

@harbaum
Copy link
Author

harbaum commented May 5, 2022

Here's a thread discussing this issue as well: https://verkehrsforum-karlsruhe.de/threads/was-ist-mit-der-kvv-live-api-passiert.280/

@Spydr06
Copy link

Spydr06 commented Jan 12, 2024

Hey everyone,
I had some time recently and worked a bit with the API, wrote a quick proof-of-concept in Rust and then went ahead and built a little departure monitor from an esp32. You can see the results and code here, but I too couldn't figure out how to filter the output. With the esp32 it works fine, since it has enough ram for the ~2kb needed per departure entry.
If I have more time, maybe I can implement proper Rust bindings for the new API.
(I know this is a bit off-topic, but maybe someone will find it helpful :))

@Spydr06
Copy link

Spydr06 commented Feb 2, 2024

Had some time, here is a proper rust crate with the bindings, although untested and not feature-complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants