Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding cancelled Trains/Bus #2

Open
d1nd141 opened this issue Jan 27, 2023 · 55 comments
Open

Question regarding cancelled Trains/Bus #2

d1nd141 opened this issue Jan 27, 2023 · 55 comments
Assignees
Labels
question Further information is requested

Comments

@d1nd141
Copy link

d1nd141 commented Jan 27, 2023

Salut,

i created a similar script for trains. (pushing data to mysql to view in grafana).
By hazard, do you know how to identify a cancelled trains/bus ?

Unfortunately the documentation provided on opendata is poor.

Villmols Merci.

@Felix3qH4 Felix3qH4 added the question Further information is requested label Jan 27, 2023
@Felix3qH4
Copy link
Owner

I would have said that „reachable“ would be equal to False in that case but that doesn‘t seem to be the case. I will have a look into that this evening.

@Felix3qH4
Copy link
Owner

So I looked into it but it doesn't seem like the data you get from the api tells you if a train/bus is cancelled or can't stop at a certain stop point. I guess that if a bus or train is cancelled, it will just disappear from the data or it will not move so the lateness will increase until a certain point where the bus/train won't be shown anyway and the lateness will be deleted.
But I can't really tell you as they don't really have a documentation and everything is very closed.
Maybe if you want you can ask the Mobilitéit.lu people how one can see that a bus/train is cancelled ([email protected]). (If you do this please let me know what they tell you as I'm interested as well.)

@d1nd141
Copy link
Author

d1nd141 commented Jan 27, 2023

Thanks for your answer.
I already contacted the opendata team on monday. Unfortunately no answer yet. Usually they answer "immediately" for API keys. So i suppose they don't give API support.
But maybe the
"prognosisType": "PROGNOSED",
field is responsible?
I don't log the entire paylod atm. Need to change the script for this.

@Felix3qH4
Copy link
Owner

I don't think that its the field "prognosisType". I believe that this field only tells us if the Bus has already started its tour and the information we have here is prognosed based on its current location so the lateness of the bus would be prognosed based on where it is and how long it takes it to get to that station you fetch the data from. Because when looking at the data from a station, the busses with the "prognosisType" field have all started their tour and all the busses that have not yet started driving don't have the "prognosisType" field.

@Felix3qH4
Copy link
Owner

I looked at the stop "Steinfort, Gemeng" (id:191104004) and this is the data I get for the bus 832:
{
"JourneyDetailRef": {
"ref": "1|4805|1|82|29012023"
},
"JourneyStatus": "P",
"Product": {
"icon": {
"foregroundColor": {
"r": 255,
"g": 255,
"b": 255,
"hex": "#FFFFFF"
},
"backgroundColor": {
"r": 117,
"g": 40,
"b": 100,
"hex": "#752864"
},
"res": "prod_bus_t"
},
"name": "Bus 832",
"num": "8100",
"line": "832",
"catOut": "Bus",
"catIn": "034",
"catCode": "5",
"cls": "32",
"catOutS": "034",
"catOutL": "Bus",
"operatorCode": "RGT",
"operator": "Régime Général des Transports Routiers",
"admin": "RGTR--",
"matchId": "832"
},
"Notes": {
"Note": [
{
"value": "RGTR",
"key": "OPERATOR",
"type": "A",
"routeIdxFrom": 5,
"routeIdxTo": 29,
"txtN": "RGTR",
"txtL": "Régime Général des Transports Routiers",
"txtS": "RGT"
}
]
},
"name": "Bus 832",
"type": "ST",
"stop": "Steinfort, Gemeng",
"stopid": "A=1@O=Steinfort, Gemeng@X=5913410@Y=49659424@U=82@L=191104004@",
"stopExtId": "191104004",
"prognosisType": "PROGNOSED",
"time": "12:24:00",
"date": "2023-01-29",
"rtTime": "12:25:00",
"rtDate": "2023-01-29",
"reachable": true,
"direction": "Redange/Attert, Lycée Atert",
"trainNumber": "832",
"trainCategory": "034"
}

as you can see it has the "prognosisType" field and it started its tour at 12:05, I called the API at 12:16 or so.

@d1nd141
Copy link
Author

d1nd141 commented Jan 29, 2023

Correct.
But afaik the field rtTime is responsible to tell us of the real time data.
So when a bus/train did not yet start, the rtTime field is missing ?!
If this is correct, every product that has started will be PROGNOSED and has an rtTime field.

@Felix3qH4
Copy link
Owner

For the bus 741 there is no "prognosisType" field as it only starts its tour at 12:24 so after I called the API:
{
"JourneyDetailRef": {
"ref": "1|4625|1|82|29012023"
},
"JourneyStatus": "P",
"Product": {
"icon": {
"foregroundColor": {
"r": 255,
"g": 255,
"b": 255,
"hex": "#FFFFFF"
},
"backgroundColor": {
"r": 117,
"g": 40,
"b": 100,
"hex": "#752864"
},
"res": "prod_bus_t"
},
"name": "Bus 741",
"num": "7653",
"line": "741",
"catOut": "Bus",
"catIn": "034",
"catCode": "5",
"cls": "32",
"catOutS": "034",
"catOutL": "Bus",
"operatorCode": "RGT",
"operator": "Régime Général des Transports Routiers",
"admin": "RGTR--",
"matchId": "741"
},
"Notes": {
"Note": [
{
"value": "RGTR",
"key": "OPERATOR",
"type": "A",
"routeIdxFrom": 3,
"routeIdxTo": 16,
"txtN": "RGTR",
"txtL": "Régime Général des Transports Routiers",
"txtS": "RGT"
}
]
},
"name": "Bus 741",
"type": "ST",
"stop": "Steinfort, Gemeng",
"stopid": "A=1@O=Steinfort, Gemeng@X=5913410@Y=49659424@U=82@L=191104004@",
"stopExtId": "191104004",
"time": "12:28:00",
"date": "2023-01-29",
"reachable": true,
"direction": "Kleinbettingen, Gare routière",
"trainNumber": "741",
"trainCategory": "034"
}

@Felix3qH4
Copy link
Owner

Correct. But afaik the field rtTime is responsible to tell us of the real time data. So when a bus/train did not yet start, the rtTime field is missing ?! If this is correct, every product that has started will be PROGNOSED and has an rtTime field.

Thats what I would say, every bus that has not started yet is missing the fields "prognosisType", "rtTime" and "rtDate"

@d1nd141
Copy link
Author

d1nd141 commented Jan 29, 2023

I'm logging all payloads received since this morning (for Trains Bascharage-Lux & Lux-Bascharage)
Hopefully i fill find a cancelled train soon, then we can compare the payloads.

But as i gave up taking trains, in favor of my car, i will have to check regularly, or maybe someone in the public Facebook group will post a message.

@Felix3qH4
Copy link
Owner

Yeah, altough it would actually be great to have some sort of documentation for the api to see what some fields mean.
But I guess we are not on that point yet. (Maybe I'll start creating a documentation, would be fun little project)

@Felix3qH4
Copy link
Owner

@Felix3qH4
Copy link
Owner

There are some lines that are not working today

@Felix3qH4
Copy link
Owner

Les courses 655 3406, 4126, 4846, 5566, 3791, 4511 et 5231 seront supprimées.

@d1nd141
Copy link
Author

d1nd141 commented Jan 29, 2023

Do you have an easy way to take the station id from the nearest_stop api? Searching by coordinates and google maps is annoying ;-)

@Felix3qH4
Copy link
Owner

{
"Departure": [
{
"JourneyDetailRef": {
"ref": "1|2427|0|82|29012023"
},
"JourneyStatus": "P",
"Product": {
"icon": {
"foregroundColor": {
"r": 255,
"g": 255,
"b": 255,
"hex": "#FFFFFF"
},
"backgroundColor": {
"r": 117,
"g": 40,
"b": 100,
"hex": "#752864"
},
"res": "prod_bus_t"
},
"name": "Bus 655",
"num": "1588",
"line": "655",
"catOut": "Bus",
"catIn": "063",
"catCode": "5",
"cls": "32",
"catOutS": "063",
"catOutL": "Bus",
"operatorCode": "RGT",
"operator": "Régime Général des Transports Routiers",
"admin": "RGTR--",
"matchId": "655"
},
"Notes": {
"Note": [
{
"value": "RGTR",
"key": "OPERATOR",
"type": "A",
"routeIdxFrom": 17,
"routeIdxTo": 39,
"txtN": "RGTR",
"txtL": "Régime Général des Transports Routiers",
"txtS": "RGT"
},
{
"value": "Bus 655: Supprimé",
"key": "text.realtime.journey.cancelled",
"type": "R",
"txtN": "Bus 655: Supprimé"
},
{
"value": "Arrêt non desservi",
"key": "text.realtime.stop.cancelled",
"type": "R",
"txtN": "Arrêt non desservi"
}
]
},
"name": "Bus 655",
"type": "ST",
"stop": "Leudelange, Wäschbur",
"stopid": "A=1@O=Leudelange, Wäschbur@X=6064411@Y=49566970@U=82@L=220701016@",
"stopExtId": "220701016",
"time": "13:08:00",
"date": "2023-01-29",
"cancelled": true,
"reachable": false,
"direction": "Alzingen, Réiserwee",
"trainNumber": "655",
"trainCategory": "063"
}
],
"TechnicalMessages": {
"TechnicalMessage": [
{
"value": "2023-01-29 12:30:29",
"key": "requestTime"
},
{
"value": " hafas:https://localhost:12003",
"key": "backendId"
},
{
"value": "ttp=15731#15826 plancode0=zdgtm planid=1674725592 planid0=1674725592 planid_adr=1630921671 plancode_adr=9alh1 planid_poi=1662965857 plancode_poi=sdeyb srvv=5.45.MMILUX.1.8.0 tlibv=Dummy-Tariflib v0.00 jno=1",
"key": "backendInfo"
}
]
},
"serverVersion": "2.7.6",
"dialectVersion": "1.29",
"planRtTs": 1674991824000,
"requestId": "kcw8rgkm6qcm94wx"
}

@Felix3qH4
Copy link
Owner

there you have the "key":"cancelled"

@d1nd141
Copy link
Author

d1nd141 commented Jan 29, 2023

and also "reachable": false
but i think cancelled is more reliable

@Felix3qH4
Copy link
Owner

yes because maybe reachable is also used in case a bus won't drive to a certain stop so its set to false for that stop but the bus is not cancelled

@Felix3qH4
Copy link
Owner

Do you have an easy way to take the station id from the nearest_stop api? Searching by coordinates and google maps is annoying ;-)

Just ask the api which stops exist: (replace with your key)

https://cdt.hafas.de/opendata/apiserver/location.nearbystops?accessId=&originCoordLong=6.09528&originCoordLat=49.77723&maxNo=5000&r=100000&format=json

and in the browser pres F3 to search and enter the name like Leudelangen, Wäschbuer

then look for "extid" or "id" somewhere around the higlighted text and enter it in the next api call where you replace with the id you found: (and )

https://cdt.hafas.de/opendata/apiserver/departureBoard?accessId=&lang=fr&format=json&id=

@Felix3qH4
Copy link
Owner

i usually have one tab where all the stops are and one where i just replace the id when i want to look at another stop

@d1nd141
Copy link
Author

d1nd141 commented Jan 29, 2023

i take the Application Postman for all API stuff. Great app when using with variables.

@Felix3qH4
Copy link
Owner

oh yeah i know it, used it for some other projects but i created this project with the mobiliteit.lu api nearly a year ago and back then I was less experienced so everything was done a bit rough as you can maybe see in my code, its a bit of a mess.

@Felix3qH4
Copy link
Owner

Btw I created a repository fo a documentation and I invite you to add any information thats missing or wrong or you think would be useful for people who don't know the api so that in the end there is at least some documentation available for it.

https://github.com/Felix3qH4/Mobiliteit.lu-API-documentation/blob/15e1dd2a0f84189dbf0cc9fc1512d10e5f948280/documentation.md

@d1nd141
Copy link
Author

d1nd141 commented Jan 29, 2023

Btw I created a repository fo a documentation and I invite you to add any information thats missing or wrong or you think would be useful for people who don't know the api so that in the end there is at least some documentation available for it.

https://github.com/Felix3qH4/Mobiliteit.lu-API-documentation/blob/15e1dd2a0f84189dbf0cc9fc1512d10e5f948280/documentation.md

Tried to commit some small changes:
You don't have permissions to push to "Felix3qH4/Mobiliteit" on GitHub. Would you like to create a fork and push to it instead?

@Felix3qH4
Copy link
Owner

yes you cannot push directly to the repository.
You have to fork it, then modify your fork and push your fork to the project.
So we avoid overwrites of someone elses content just because we might have an older version.

@d1nd141
Copy link
Author

d1nd141 commented Feb 3, 2023

Hi again,

i'm monitoring now 4 train stations:

Lux-Bascharage
Bascharage-Lux
Ettelbrück-Lux
Lux-Ettelb.

I noticed that route Bascharage-Lux has lots of delays, while on the other routes, the counter is nearly all the time 0.
Therefor i SUPPOSE that the departure in Bascharage is the only one, where a train starts with a delay. (+1min etc)

I added Ettelb due to the latest complains on FB etc.

So in theory, we would have to monitor not only the departure at a station, but also the arrival ?!
image

image

@Felix3qH4
Copy link
Owner

Well if in your request you filter by arrival/departure you would have to add thr other one too. But if you just do a simple request without telling it if you want departures or arrivals only and without saying that you only want trains going to a certain direction, then you wouldn't need to check for departures and arrivals.
So if you just ask for the trains at a station you get both directions to say it in an easy way. And then you can just look at "rtTime" to see when it will arrive and calculate the difference between the scheduled time which is "time" I believe or smth like that.

@Felix3qH4
Copy link
Owner

Altough it is weird that all trains coming from LUX to Bascharage have 0 lateness. I can't really believe that. I will have a look this evening if I have time, otherwise maybe on Sunday.

@Felix3qH4
Copy link
Owner

Screenshot_20230203_121221_mobiliteitlu.jpg

@d1nd141
Copy link
Author

d1nd141 commented Feb 3, 2023

Strange, the payload received at 12:00:00 was without rttime (so i'm putting time in mysql)
{"Departure": [{"JourneyDetailRef": {"ref": "1|1307|0|82|3022023"}, "JourneyStatus": "P", "Product": {"icon": {"foregroundColor": {"r": 255, "g": 255, "b": 255, "hex": "#FFFFFF"}, "backgroundColor": {"r": 209, "g": 0, "b": 116, "hex": "#D10074"}, "res": "prod_reg"}, "name": "RE 86562", "num": "86562", "line": "RE", "catOut": "RE", "catIn": "RE", "catCode": "2", "cls": "4", "catOutS": "RE", "catOutL": "RE", "operatorCode": "CFL", "operator": "Chemins de Fer Luxembourgeois", "admin": "C82---", "matchId": "RE"}, "Notes": {"Note": [{"value": "CFL", "key": "OPERATOR", "type": "A", "routeIdxFrom": 0, "routeIdxTo": 6, "txtN": "CFL", "txtL": "Chemins de Fer Luxembourgeois", "txtS": "CFL"}, {"value": "bicycle transport / service pour bicyclettes / Fahrradmitnahme", "key": "71", "type": "A", "priority": 1, "routeIdxFrom": 0, "routeIdxTo": 6, "txtN": "bicycle transport / service pour bicyclettes / Fahrradmitnahme"}]}, "name": "RE 86562", "type": "ST", "stop": "Luxembourg, Gare Centrale", "stopid": "A=1@O=Luxembourg, Gare Centrale@X=6134239@Y=49599969@U=82@L=200405060@", "stopExtId": "200405060", "time": "12:04:00", "date": "2023-02-03", "reachable": true, "direction": "Longwy, Gare", "trainNumber": "86562", "trainCategory": "RE"}, {"JourneyDetailRef": {"ref": "1|1043|1|82|3022023"}, "JourneyStatus": "P", "Product": {"icon": {"foregroundColor": {"r": 255, "g": 255, "b": 255, "hex": "#FFFFFF"}, "backgroundColor": {"r": 209, "g": 0, "b": 116, "hex": "#D10074"}, "res": "prod_reg"}, "name": "RB 4712", "num": "4712", "line": "RB", "catOut": "RB", "catIn": "CRB", "catCode": "2", "cls": "4", "catOutS": "CRB", "catOutL": "RB", "operatorCode": "CFL", "operator": "Chemins de Fer Luxembourgeois", "admin": "C82---", "matchId": "RB"}, "Notes": {"Note": [{"value": "CFL", "key": "OPERATOR", "type": "A", "routeIdxFrom": 0, "routeIdxTo": 9, "txtN": "CFL", "txtL": "Chemins de Fer Luxembourgeois", "txtS": "CFL"}, {"value": "bicycle transport / service pour bicyclettes / Fahrradmitnahme", "key": "71", "type": "A", "priority": 1, "routeIdxFrom": 0, "routeIdxTo": 9, "txtN": "bicycle transport / service pour bicyclettes / Fahrradmitnahme"}]}, "name": "RB 4712", "type": "ST", "stop": "Luxembourg, Gare Centrale", "stopid": "A=1@O=Luxembourg, Gare Centrale@X=6134239@Y=49599969@U=82@L=200405060@", "stopExtId": "200405060", "time": "12:20:00", "date": "2023-02-03", "reachable": true, "direction": "Athus, Gare", "trainNumber": "4712", "trainCategory": "CRB"}, {"JourneyDetailRef": {"ref": "1|1307|1|82|3022023"}, "JourneyStatus": "P", "Product": {"icon": {"foregroundColor": {"r": 255, "g": 255, "b": 255, "hex": "#FFFFFF"}, "backgroundColor": {"r": 209, "g": 0, "b": 116, "hex": "#D10074"}, "res": "prod_reg"}, "name": "RE 86564", "num": "86564", "line": "RE", "catOut": "RE", "catIn": "RE", "catCode": "2", "cls": "4", "catOutS": "RE", "catOutL": "RE", "operatorCode": "CFL", "operator": "Chemins de Fer Luxembourgeois", "admin": "C82---", "matchId": "RE"}, "Notes": {"Note": [{"value": "CFL", "key": "OPERATOR", "type": "A", "routeIdxFrom": 0, "routeIdxTo": 6, "txtN": "CFL", "txtL": "Chemins de Fer Luxembourgeois", "txtS": "CFL"}, {"value": "bicycle transport / service pour bicyclettes / Fahrradmitnahme", "key": "71", "type": "A", "priority": 1, "routeIdxFrom": 0, "routeIdxTo": 6, "txtN": "bicycle transport / service pour bicyclettes / Fahrradmitnahme"}]}, "name": "RE 86564", "type": "ST", "stop": "Luxembourg, Gare Centrale", "stopid": "A=1@O=Luxembourg, Gare Centrale@X=6134239@Y=49599969@U=82@L=200405060@", "stopExtId": "200405060", "time": "12:34:00", "date": "2023-02-03", "reachable": true, "direction": "Longwy, Gare", "trainNumber": "86564", "trainCategory": "RE"}, {"JourneyDetailRef": {"ref": "1|1043|2|82|3022023"}, "JourneyStatus": "P", "Product": {"icon": {"foregroundColor": {"r": 255, "g": 255, "b": 255, "hex": "#FFFFFF"}, "backgroundColor": {"r": 209, "g": 0, "b": 116, "hex": "#D10074"}, "res": "prod_reg"}, "name": "RB 5062", "num": "5062", "line": "RB", "catOut": "RB", "catIn": "CRB", "catCode": "2", "cls": "4", "catOutS": "CRB", "catOutL": "RB", "operatorCode": "CFL", "operator": "Chemins de Fer Luxembourgeois", "admin": "C82---", "matchId": "RB"}, "Notes": {"Note": [{"value": "CFL", "key": "OPERATOR", "type": "A", "routeIdxFrom": 0, "routeIdxTo": 9, "txtN": "CFL", "txtL": "Chemins de Fer Luxembourgeois", "txtS": "CFL"}, {"value": "bicycle transport / service pour bicyclettes / Fahrradmitnahme", "key": "71", "type": "A", "priority": 1, "routeIdxFrom": 0, "routeIdxTo": 9, "txtN": "bicycle transport / service pour bicyclettes / Fahrradmitnahme"}]}, "name": "RB 5062", "type": "ST", "stop": "Luxembourg, Gare Centrale", "stopid": "A=1@O=Luxembourg, Gare Centrale@X=6134239@Y=49599969@U=82@L=200405060@", "stopExtId": "200405060", "time": "12:50:00", "date": "2023-02-03", "reachable": true, "direction": "Athus, Gare", "trainNumber": "5062", "trainCategory": "CRB"}], "TechnicalMessages": {"TechnicalMessage": [{"value": "2023-02-03 12:00:06", "key": "requestTime"}, {"value": " hafas:https://localhost:12001", "key": "backendId"}, {"value": "ttp=15731#15826 plancode0=zdgtm planid=1674725592 planid0=1674725592 planid_adr=1630921671 plancode_adr=9alh1 planid_poi=1662965857 plancode_poi=sdeyb srvv=5.45.MMILUX.1.8.0 tlibv=Dummy-Tariflib v0.00 jno=2", "key": "backendInfo"}]}, "serverVersion": "2.7.6", "dialectVersion": "1.29", "planRtTs": 1675421984000, "requestId": "xqi6kg24misf8kwg"}

@Felix3qH4
Copy link
Owner

Maybe the trains had not started yet at that time. Then there is no rtTime field.

@Felix3qH4
Copy link
Owner

Yes in the json you sent, the first departure seems to be at 12:04

@Felix3qH4
Copy link
Owner

Screenshot_20230203_125720_mobiliteitlu.jpg

@Felix3qH4
Copy link
Owner

Felix3qH4 commented Feb 3, 2023

This is the first train in your json and it starts at LUX gare but only at 12:04 so 4 minutes after you retrieved the data. So at that time there is not yet rtTime, it will be available at 12:04

If it had already been driving it would have had the rtTime attribute.

@Felix3qH4
Copy link
Owner

Felix3qH4 commented Feb 3, 2023

So maybe your data was based on trains that had not yet departed?
So they could not be late.

And I guess that at the start point (LUX gare) the train cannot be late as it just started.

@d1nd141
Copy link
Author

d1nd141 commented Feb 3, 2023

I rescheduled my requests to every minute now (instead of */5 ).
Let's see if this helps.

@Felix3qH4
Copy link
Owner

What you could do is have a dictionary in which you put the lines. So after each request you check if the line is alteady in the dict and if yes, check if it already has the rtTime attribute, if yes and the new lateness is bigger than the old one, replace the lateness with the new one, otherwise just skip it. That way you can fetch the data continuously and you can just wait until the rtTime tag is there. Or when you do a request just filter all the lines out that do not have an rtTime tag.

@d1nd141
Copy link
Author

d1nd141 commented Feb 3, 2023

Possibly my issue is:
My request looks like:
https://cdt.hafas.de/opendata/apiserver/departureBoard?accessId=xxxxx&format=json&id=140701022&rtMode=FULL&direction=200405060&operators=CFL

Therefor i'm only checking departure Ettelbrück with destination Lux. (direction)
Imagine i do the following:

https://cdt.hafas.de/opendata/apiserver/departureBoard?accessId=xxxxx&format=json&id=140701022&rtMode=FULL&operators=CFL

https://cdt.hafas.de/opendata/apiserver/departureBoard?accessId=xxxx&format=json&rtMode=FULL&id=200405060&operators=CFL

Without the direction, i would receive departure Ettelbrück, but not arrival Lux. Only departure Lux, but this would change the Train number again. (A train arrived at Lux will (probably) return to Ettelbrück with a different train number)

@Felix3qH4
Copy link
Owner

yeah but then you have to do the same request as your first one but with the ids inverted to get the lateness for trains from LUX to Ettelbrück. You can't use the same request for both directions.
And yes a train that arrived at LUX will probably return to Ettelbrück, but that is a different line. Like its not the same anymore, so you should treat it like this. It is a completely new route and line, even if the conductor and the train might be the same.

@Felix3qH4
Copy link
Owner

Btw, I wrote to the API people on Tuesday to ask if there is an official documentation and not only the xml defintion on the api site.
I got no answer yet, but I will send the same email every week until they at least respond that they don't have one.
When emailing them it might also be good to put the mobiliteit.lu email in CC because when I asked for an API key I got no answer for weeks but when I sent another email and put them in CC I got my key the day after.

@d1nd141
Copy link
Author

d1nd141 commented Feb 3, 2023

yeah but then you have to do the same request as your first one but with the ids inverted to get the lateness for trains from LUX to Ettelbrück. You can't use the same request for both directions. And yes a train that arrived at LUX will probably return to Ettelbrück, but that is a different line. Like its not the same anymore, so you should treat it like this. It is a completely new route and line, even if the conductor and the train might be the same.

Of course I'm always using 2 requests:
url = "https://cdt.hafas.de/opendata/apiserver/departureBoard?accessId=xxxxx&format=json&id=190101027&rtMode=FULL&direction=200405060&operators=CFL"
and
url = "https://cdt.hafas.de/opendata/apiserver/departureBoard?accessId=xxxxx&format=json&direction=190101027&rtMode=FULL&id=200405060&operators=CFL"

But as said, you only have the departure when leaving station Ettelbrück, Lux, or Bascharage.
When a Train/Bus has a delay after the initial departure, you will never notice, as no arrival time / arrival api.

Regarding email:
Good idea! Will do the same! Do you have the mobiliteit.lu address?
I got my api key in approx 2 days.

@Felix3qH4
Copy link
Owner

As for the email, back when I was asking for the API key, I did some research and found it: [email protected]
But on their site they don't display it as fas as I know. (Probably so they don't get spammed by bots scraping the web for emails)

@Felix3qH4
Copy link
Owner

And as for the delay, you will have to make a request at the final destination and check the final delay there, or at each stop as the delay changes between stops.
So for a train departing at LUX Gare, stopping at Gare XX and at Gare YY with final destination Ettelbrück, you would have to either ask the final destination (Ettelbrück) how late this line is, by requesting all arrivals/departures and filtering for your line.
Or you can do that at Gare XX and then at Gare YY and then at Gare Ettelbrück, then you always have the up-to-date lateness.

@Felix3qH4
Copy link
Owner

It would be helpful if there was a feature where you could just enter your line and then get all the information like all stops, how late it is etc., but I asked them last year and they said that it is not possible but they would discuss it internally. But I am sure they didn't implement it as they bought the system from HAFAS and probably never touched it afterwards. The API keys are probably even given by HAFAS, so they ask HAFAS for a key when you ask them for a key.

@Felix3qH4
Copy link
Owner

Felix3qH4 commented Feb 3, 2023

Because in the xml definition there are some errors and its so incomplete that you can't tell me someone worked with/on that.

@d1nd141
Copy link
Author

d1nd141 commented Feb 3, 2023

According to
https://bvg-hackathon-2018.devpost.com/forum_topics/7874-hacon-api-access-to-bvg-journey-planner
There was an arrivalboard api. But seems either disabled or not existing anymore.

I completely agree with you. They probably payed the company (hafas) to implement this, and never touched after.
Or they don't want do give you too much information, because you could export the real statistics and make public....

@Felix3qH4
Copy link
Owner

Oooohhh thanks for the link, there is some more documentation for the api even if its not exactly the same.

@Felix3qH4
Copy link
Owner

And yes if you look at other countries or other enterprises which use this API they usually have way more functions than the 2 we have. And yes that is quite possible that they don't actually want you to have too much information.

@d1nd141
Copy link
Author

d1nd141 commented Feb 3, 2023

Indeed.
Or they did not pay for more features ;-)
DB and CH give a more complex documentation of the API.
There is also a js
https://github.com/public-transport/hafas-client/blob/master/p/mobiliteit-lu/example.js
But i hate everything related to java and js.

@Felix3qH4
Copy link
Owner

Or they did not pay for more features ;-)
haha that could even be possible :)

I will have a look at the js code maybe tomorrow if I have time, otherwise on Sunday and I'll also look at the link you sent before more in detail. Maybe I can extract some knowledge from the js code altough I'm no fan either :)

I would actually love to know what tools the Leetstell is working with https://www.mobiliteit.lu/en/about-us/leetstell/
that would be nice as I could maybe create smth similar.

@Felix3qH4
Copy link
Owner

I found a folder of data which mobiliteit.lu has to upload to hafas for the api so based on what is in there one can understand a bit more about the api and what the return values mean.
If you have a look at it I recommend looking at the Hafas documentation at the same time because then many things will make a lot more sense in the documentation. https://inno.hafas.de/bvg-hackathon-2018/HAFAS_ReST_Interface_v.1.23.23.pdf

@Felix3qH4
Copy link
Owner

Its the 'opendata' folder

@d1nd141
Copy link
Author

d1nd141 commented Feb 5, 2023

Don't understand what you mean with the opendata folder. Sry

@Felix3qH4
Copy link
Owner

You have probably already looked at the Hafas documentation (the link I sent in the comment)?
There are many details explained about what the return values are like the values you get from the API when you make a request.
But many things are poorly explained so that without having access to the files I just uploaded as folder to the github, it is really difficult or nearly impossible to understand many things in the documentation. Thanks to the files many things become clearer. But you can't just look at the files, you have to look at the documentation whilst looking at the files otherwise its still gibberish.

@d1nd141
Copy link
Author

d1nd141 commented Feb 5, 2023

My bad, missed the opendata folder on git here ;-)
Will take a look.
Tks

@Felix3qH4 Felix3qH4 self-assigned this Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants