lvb
lvb copied to clipboard
get all stations from the API
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
Sorry for the very late response. Unfortunately, there is no such endpoint available, as fas as I know. Maybe @hashworks knows more?
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.
Liste der Haltestelle haltestellen.txt n