lvb icon indicating copy to clipboard operation
lvb copied to clipboard

get all stations from the API

Open ghost opened this issue 5 years ago • 3 comments

Hi there,

is it possible to get all single stations from the API?

I want to implement this in Node Red and select the stations via dropdown.

Kind regards Alex

ghost avatar Jan 08 '20 15:01 ghost

Sorry for the very late response. Unfortunately, there is no such endpoint available, as fas as I know. Maybe @hashworks knows more?

juliuste avatar Jul 10 '20 18:07 juliuste

You can use the autocomplete API to get a list of all stations: $ curl "https://www.l.de/ajax_de?mode=autocomplete&q=&poi=&limit=2" | jq

{
  "stations": [
    {
      "name": "Leipzig, Markt",
      "lat": "51.339882282118",
      "lng": "12.374237209778",
      "distance": "0.078350872860768"
    },
    {
      "name": "Leipzig, Reichsstraße",
      "lat": "51.341836324787",
      "lng": "12.376662567095",
      "distance": "0.19867293290099325"
    }
  ]
}

You can set the limit as high as you like!

$ curl "https://www.l.de/ajax_de?mode=autocomplete&q=&poi=&limit=1000" | jq | grep name | wc -l`
877

So, this endpoint returns up to 877 stations. A word of warning: Don't call this too often, or they might add a hard limit. Cache it, updating it every few weeks should be quite enough.

As you see this will only provide you with the station names, so after you select one you still have to call the stations API to acquire the ID.

Maybe I'll have time to implement this later, but we really need to cache it.

hashworks avatar Jul 11 '20 11:07 hashworks

Liste der Haltestelle haltestellen.txt n

Rennbahn2000 avatar Mar 13 '22 14:03 Rennbahn2000