Open derhuerst opened 1 year ago
@TheRealMurmel FYI: Implementing the "best price search" feature here in hafas-client
, as described above, would be quite straightforward, as most of the response structure is already supported.
@derhuerst I would really like to provide more help, but I'm note quite sure when I will have time to contribute here.
@derhuerst I built a small Python-based project to replay the relevant API requests, this might help someone else to re-implement the requests into hafas-client:
BTW, if you're more comfortable tinkering with Python instead of JS, adding support for "best price search" to pyhafas would also be an option! We can then port the code over to hafas-client.
I'll give it a try!
@bergmannjg has built an "MVP" implementation of this.
@bergmannjg has built an "MVP" implementation of this.
It's nothing more than replacing
meth: "TripSearch"
with
meth: "BestPriceSearch"
in the corresponding HAFAS request.
It works.
@derhuerst said
Not sure how this functionality should be exposed:
- We could let journeys() always parse & expose a grouping/bracketing of journeys as soon as the HAFAS response contains it. A DB-specific opt.bestPriceSearch option would use BestPriceSearch and outTime: "000000".
- Within the DB profile, we could implement it as an entirely separate hafas-client method. It would have to share much of the logic with journeys(). Currently, we don't have a mechanism to let profiles add methods though.
I would propose to add an new method to the hafas-client API because the bestprice search options are only a subset of the journey search options and the results are different.
Here is my (not yet complete) implementation
Is this planned to be merged? / worked on?
Here is my (not yet complete) implementation
I am running this for a few days already without problems, just added the date as a parameter.
Both the Deutsche Bahn (DB) website as well as their app have a feature called "best price search" or "Bestpreissuche", which works just like the regular
journeys()
(TripSearch
in HAFAS), except that it returns the lowest-price journeys for each time bracket.The details of this
BestPriceSearch
call are documented at https://github.com/juliuste/db-prices/issues/33#issuecomment-1538776446 . It's response data looks like the one of aTripSearch
call, but it also has a fieldres.outDaySegL
that groups the journeys inres.outConL[]
into time brackets.Not sure how this functionality should be exposed:
journeys()
always parse & expose a grouping/bracketing of journeys as soon as the HAFAS response contains it. A DB-specificopt.bestPriceSearch
option would useBestPriceSearch
andoutTime: "000000"
.hafas-client
method. It would have to share much of the logic withjourneys()
. Currently, we don't have a mechanism to let profiles add methods though.pyhafas equivalent Issue: https://github.com/FahrplanDatenGarten/pyhafas/issues/26