lvb icon indicating copy to clipboard operation
lvb copied to clipboard

LVB API no longer uses IDs

Open hashworks opened this issue 4 years ago • 3 comments

Looks like the LVB API no longer provides station IDs in the AJAX response:

$ curl https://www.l.de/ajax_de?mode=autocomplete&q=Herman&poi=&limit=10
{"stations":[{"name":"Leipzig, Hermann-Liebmann-Str.\/ Eisenbahnstr.","lat":"51.345578950648","lng":"12.406472923894","distance":"2.272732820253887"},{"name":"Leipzig, Dr.-Hermann-Duncker-Str.","lat":"51.333249688312","lng":"12.305794850988","distance":"4.849646498628953"}]}

/fahrplan/abfahrten now uses the whole name instead: request

The lvb.departures test is wrong at that point: Providing the ID results in the departures of a different station.

hashworks avatar Oct 25 '21 10:10 hashworks

So basically, const d = await departures("Leipzig, Hermann-Liebmann-Str./+Eisenbahnstr.", Date.now()) is the way to do things now. Looks like "stations" should only return the "proper" names.

hashworks avatar Oct 25 '21 10:10 hashworks

The package originally included a workaround for that by making departure requests for every station by their name to obtain the ids. This workaround was still in the code, but failing silently. I fixed it now, even though it's ugly, of course, since it requires additional requests. We should probably remove the IDs and switch to names completely.

juliuste avatar Oct 25 '21 10:10 juliuste

It seems, they complete removed the API, at least the https://www.l.de/verkehrsbetriebe/fahrplan/ doesn't use the form data call anymore, I only see some reiseauskunft.insa.de and some hafas-client library code calls.

joergreichert avatar Dec 11 '21 19:12 joergreichert