derhuerst / vbb-rest

An HTTP API for Berlin & Brandenburg public transport.
https://v6.vbb.transport.rest/
ISC License
123 stars 14 forks source link

Filter departures and arrivals by line id #51

Open RBeerDevelopment opened 1 year ago

RBeerDevelopment commented 1 year ago

Currently the /stops/:id/departures and the /stops/:id/arrivals only take the direction and the duration as filter arguments. However, sometimes it would also be interesting (or easier) to filter by a specific line (eg. ?line=u5) or do this in addition to the existing filters.

derhuerst commented 1 year ago

This is tricky, because the VBB HAFAS API used by vbb-rest

Also, even if the VBB HAFAS API returned proper line IDs, hafas-client wouldn't parse & expose them (just as id with fallback to slugg(name), which is not usable for filtering):

https://github.com/public-transport/hafas-client/blob/f530a30fe019f3c8e19a4eb0f15fa99776db6f7e/parse/line.js#L8-L20

But hafas-client already supports filtering by such "line IDs":

https://github.com/public-transport/hafas-client/blob/f530a30fe019f3c8e19a4eb0f15fa99776db6f7e/index.js#L60

Let's wait until the VBB HAFAS API returns them, then we can implement this for vbb-rest.

derhuerst commented 1 year ago

In any case, having this filtering by "line ID" in hafas-rest-api would be beneficial for all HAFAS APIs that return them – specifically, db-rest would gain this functionality. If you want to implement this, please submit a Pull Request! 🙌