Open gagni opened 1 year ago
Hey, the API this repo uses seems to be unavailable since 2-3 days. I'm currently looking for a workaround, but that might take a few days/weeks. Will update this repo once I found a replacement.
Hey, i have the same issue. Is there tentative timeframe when this will be solved? Thanks!
do you have any news ?
I had a look at the network traffic.
App
The app displays the following connections and their prices:
Request
In order to obtain the prices, the app does the following request:
POST /bin/mgate.exe?checksum=bac6e939533c25bb9d19781735fb165d HTTP/1.1
User-Agent: Dalvik/2.1.0 (Linux; U; Android 9; unknown Build/PI)
Content-Type: application/json;charset=UTF-8
Host: reiseauskunft.bahn.de
Connection: close
Accept-Encoding: gzip, deflate
Content-Length: 629
{
"auth": {
"aid": "n91dB8Z77MLdoR0K",
"type": "AID"
},
"client": {
"id": "DB",
"name": "DB Navigator",
"os": "Android 9",
"res": "1080x2028",
"type": "AND",
"ua": "Dalvik/2.1.0 (Linux; U; Android 9; unknown Build/PI)",
"v": 22080000
},
"ext": "DB.R22.04.a",
"formatted": false,
"lang": "eng",
"svcReqL": [
{
"cfg": {
"polyEnc": "GPA"
},
"meth": "Reconstruction",
"req": {
"getPasslist": true,
"getPolyline": true,
"outReconL": [
{
"ctx": "T$A=1@O=Frankfurt(Main)Hbf@L=8000105@a=128@$A=1@O=Köln Hbf@L=8000207@a=128@$202305251828$202305251931$ICE 10$$1$$$$$$"
}
],
"trfReq": {
"cType": "PK",
"directESuiteCall": true,
"jnyCl": 2,
"rType": "DB-PE",
"tvlrProf": [
{
"type": "E"
}
]
}
}
}
],
"ver": "1.15"
}
as curl:
curl -X $'POST' \
-H $'User-Agent: Dalvik/2.1.0 (Linux; U; Android 9; unknown Build/PI)' \
-H $'Content-Type: application/json;charset=UTF-8' \
-H $'Host: reiseauskunft.bahn.de' \
-H $'Accept-Encoding: deflate' \
--data-binary $'{\"auth\":{\"aid\":\"n91dB8Z77MLdoR0K\",\"type\":\"AID\"},\"client\":{\"id\":\"DB\",\"name\":\"DB Navigator\",\"os\":\"Android 9\",\"res\":\"1080x2028\",\"type\":\"AND\",\"ua\":\"Dalvik/2.1.0 (Linux; U; Android 9; unknown Build/PI)\",\"v\":22080000},\"ext\":\"DB.R22.04.a\",\"formatted\":false,\"lang\":\"eng\",\"svcReqL\":[{\"cfg\":{\"polyEnc\":\"GPA\"},\"meth\":\"Reconstruction\",\"req\":{\"getPasslist\":true,\"getPolyline\":true,\"outReconL\":[{\"ctx\":\"T$A=1@O=Frankfurt(Main)Hbf@L=8000105@a=128@$A=1@O=K\xc3\xb6ln Hbf@L=8000207@a=128@$202305251828$202305251931$ICE 10$$1$$$$$$\"}],\"trfReq\":{\"cType\":\"PK\",\"directESuiteCall\":true,\"jnyCl\":2,\"rType\":\"DB-PE\",\"tvlrProf\":[{\"type\":\"E\"}]}}}],\"ver\":\"1.15\"}' \
$'https://reiseauskunft.bahn.de/bin/mgate.exe?checksum=bac6e939533c25bb9d19781735fb165d'
Response
This is the reponse (I removed some parts in order to make it easier to crasp the relevant section):
{
"ver": "1.15",
"ext": "DB.R22.04.a",
"lang": "eng",
"id": "w2ki6j4mg44xx28x",
"cInfo": ...,
"svcResL": [
{
"meth": "Reconstruction",
"err": "OK",
"res": {
"common": ...,
"outConL": [
{
"cid": "DirectConReq-0",
"date": "20230525",
"dur": "010300",
"chg": 0,
"sDays": ...,
"dep": ...
"arr": ...,
"secL": ...,
"ctxRecon": "T$A=1@O=Frankfurt(Main)Hbf@L=8000105@a=128@$A=1@O=Köln Hbf@L=8000207@a=128@$202305251828$202305251931$ICE 10$$1$$$$$$",
"trfRes": {
"fareSetL": [
{
"fareL": ...,
"addData": "...",
"prc": 5590
},
...
],
...
},
...
}
],
...
}
}
]
}
So the price is located at svcResL[0].res.outConL[0].trfRes.fareSetL[0].prc
I updated my previous comment in order to provide the curl command for the request, the response and a screenshot of the app
I had a look at the network traffic. […] The app displays the following connections and their prices:
The problem is that this request
With respect to your first comment, the best price option triggers the following request:
curl -X $'POST' \
-H $'User-Agent: Dalvik/2.1.0 (Linux; U; Android 9; Pixel 3 Build/PI)' \
-H $'Content-Type: application/json;charset=UTF-8' \
-H $'Host: reiseauskunft.bahn.de' \
-H $'Accept-Encoding: deflate' \
--data-binary $'{\"auth\":{\"aid\":\"n91dB8Z77MLdoR0K\",\"type\":\"AID\"},\"client\":{\"id\":\"DB\",\"name\":\"DB Navigator\",\"os\":\"Android 9\",\"res\":\"1080x2028\",\"type\":\"AND\",\"ua\":\"Dalvik/2.1.0 (Linux; U; Android 9; Pixel 3 Build/PI)\",\"v\":22080000},\"ext\":\"DB.R22.04.a\",\"formatted\":false,\"lang\":\"eng\",\"svcReqL\":[{\"cfg\":{\"polyEnc\":\"GPA\",\"rtMode\":\"HYBRID\"},\"meth\":\"BestPriceSearch\",\"req\":{\"outDate\":\"20230525\",\"outTime\":\"183000\",\"arrLocL\":[{\"crd\":{\"x\":6959197,\"y\":50942823},\"extId\":\"8000207\",\"lid\":\"A=1@O=K\xc3\xb6ln Hbf@X=6958730@Y=50943029@U=80@L=8000207@B=1@p=1678909069@\",\"name\":\"K\xc3\xb6ln Hbf\",\"type\":\"S\"}],\"depLocL\":[{\"crd\":{\"x\":8663003,\"y\":50106817},\"extId\":\"8000105\",\"lid\":\"A=1@O=Frankfurt(Main)Hbf@X=8663785@Y=50107149@U=80@L=8000105@B=1@p=1678909069@\",\"name\":\"Frankfurt(Main)Hbf\",\"type\":\"S\"}],\"getPasslist\":true,\"getPolyline\":true,\"jnyFltrL\":[{\"mode\":\"BIT\",\"type\":\"PROD\",\"value\":\"11111111111111\"}],\"trfReq\":{\"cType\":\"PK\",\"jnyCl\":2,\"tvlrProf\":[{\"type\":\"E\"}]}}}],\"ver\":\"1.15\"}' \
$'https://reiseauskunft.bahn.de/bin/mgate.exe?checksum=b7fbc668cec93b4a6d3a24a12d9339cc'
The output is quite large, I will try to prepare a suitable snippet if I have more time.
App
Response
My first guess, the svcResL[0].res.outConL
array contains every connection. Every element of this list is identified by the cid
key which is structured as AX-z
for X
€ {0,5}, so X
most likely correspondents to the 6 time spans from the screenshot. FOr readability reasons, the following excerpt only contains the first array element. The price can be found at svcResL[0].res.outConL[0].trfRes.fareSetL[0].fareL[0].prc
for this element.
{
"ver": "1.15",
"ext": "DB.R22.04.a",
"lang": "eng",
"id": "namwkn2u2wcwggwg",
"cInfo": ...,
"svcResL": [
{
"meth": "BestPriceSearch",
"err": "OK",
"res": {
"common": ...,
"outConL": [
{
"cid": "A0-0",
"date": "20230525",
"dur": "023500",
"chg": 0,
"dep": ...,
"arr": ...,
"secL": ...,
"ctxRecon": "T$A=1@O=Frankfurt(Main)Hbf@L=8000105@a=0@$A=1@O=Köln Hbf@L=8000207@a=0@$202305250322$202305250557$IC 60402$$1$$$$$$",
"trfRes": {
"statusCode": "OK",
"fareSetL": [
{
"fareL": [
{
"prc": 1790,
"isFromPrice": true,
"isPartPrice": false,
"isBookable": true,
"isUpsell": false,
"targetCtx": "D",
"buttonText": "To offer selection",
"retPriceIsCompletePrice": false,
"retPrice": -1,
"fahrrad": false
}
]
}
]
},
"conSubscr": "U",
"resState": "N",
"resRecommendation": "N",
"recState": "U",
"sotRating": 0,
"isSotCon": false,
"showARSLink": false,
"cksum": "cf66b09d_3",
"dTrnCmpSX": ...
},
...A0-X - A5-Y...
],
"fpB": "20221211",
"fpE": "20231209",
"bfATS": -1,
"bfIOSTS": -1,
"planrtTS": "1683557525",
"outDaySegL": ...,
"outTbpState": 0
}
}
]
}
My first guess, the
svcResL[0].res.outConL
array contains every connection.
Correct.
Every element of this list is identified by the
cid
key which is structured asAX-z
forX
€ {0,5}, soX
most likely correspondents to the 6 time spans from the screenshot.
While the cid
could be used to deduce the grouping/bracketing of connections into time spans, there is explicit data expressing it in the response: For each group/bracket, the respective item in res.outDaySegL[]
contains the indices of the connections.
// outDaySegL
[
{
"conRefL": [
4,
1,
2,
3,
0
],
"id": "0",
"fromDate": "20230509",
"fromTime": "000000",
"toDate": "20230509",
"toTime": "070000",
"bestPrice": {
"amount": 9590
},
"segmentHeightIndicator": 76,
"isCompletePrice": false,
"tbpState": 0
},
// …
]
What is the way forward here? can we help somehow? What can we do to get a working client again?
Given that it seems like the old standalone "Bestpreissuche" API doesn't exist/work anymore, I think it would be best to at least implement the current functionality of the DB Navigator (finding the best prices for one day). This should be done in hafas-client
, and is being tracked in https://github.com/public-transport/hafas-client/issues/291 .
Once the new intra-day "Bestpreissuche" API is implemented in hafas-client
, we can make db-prices
use it and try to transform the data into a as-backwards-compatible-as-possible data format, so that db-prices
works again as it used to, more or less.
Are there any updates on this?
I used the bestPrice api in the hafas-client branch with success in https://github.com/thigg/fahrpreis-plotter. Seems to work without problems.
@thigg I did not find a bestPrices Funciton in https://github.com/public-transport/hafas-client. I also checked every available branch and not one createClient-Function does have a bestPrices Function. Can you help me with that?
I forked this branch on a fork: https://github.com/thigg/hafas-client/tree/add-BestPriceSearch
Am Mittwoch, 20. März 2024 schrieb zaunerp:
@thigg I did not find a bestPrices Funciton in https://github.com/public-transport/hafas-client. I also checked every available branch and not one createClient-Funktion does have a bestPrices Function. Can you help me with that?
-- Reply to this email directly or view it on GitHub: https://github.com/juliuste/db-prices/issues/33#issuecomment-2009393007 You are receiving this because you were mentioned.
Message ID: @.***
Hello,
I tried but it doesn't work, is this normal? I see that the repo is from 2019