ResRobot - issue with train number
Hi,
I have noticed a potential issue with train number («leg.product.num») in the response from the https://api.resrobot.se/v2.1/trip endpoint for SL trains. The issue is that «leg.product.num» in the response doesn’t match the train number that is shown on trafikverket.se.
For example:
https://api.resrobot.se/v2.1/trip?format=json&lang=sv&originId=740000005&destId=740000556&date=2024-08-23&time=12:00&products=510&operators=!287,!838,!324&passlist=true&showPassingPoints=true&searchForArrival=false
In that response we have an SL train that leaves from Uppsala at 12:26. When looking at the product information for the connected leg the «product.num» is 40. However, when I look up the train information at https://www.trafikverket.se/trafikinformation/tag the train number for this train is shown to be 2237.
You can see the related product data from the response below:
I have not noticed any mismatch for any other operators except SL.
Is there an error in the response or is the «leg.product.num» correct for the SL train?
I have noticed a potential issue with train number («leg.product.num») in the response from the https://api.resrobot.se/v2.1/trip endpoint for SL trains. The issue is that «leg.product.num» in the response doesn’t match the train number that is shown on trafikverket.se.
For example:
https://api.resrobot.se/v2.1/trip?format=json&lang=sv&originId=740000005&destId=740000556&date=2024-08-23&time=12:00&products=510&operators=!287,!838,!324&passlist=true&showPassingPoints=true&searchForArrival=false
In that response we have an SL train that leaves from Uppsala at 12:26. When looking at the product information for the connected leg the «product.num» is 40. However, when I look up the train information at https://www.trafikverket.se/trafikinformation/tag the train number for this train is shown to be 2237.
You can see the related product data from the response below:
I have not noticed any mismatch for any other operators except SL.
Is there an error in the response or is the «leg.product.num» correct for the SL train?
Följ inlägget
1
följare
This is by design. SL announces all trains by their line number, and travelers never see a train number. Resrobot returns responses which match what is shown on the departure boards in the stations and on travelers' tickets, which is 40, 41, 42, 42X, ... in this case.
Regards,
Bert
Thanks for explanation and the quick response. Is it possible to get the Trafikverket train number for SL trains from any other place in the response? I see that in the case described we can see that the Trafikverket train number is at det end of "product.matchId". Will the Trafikverket train number always be at the end of "product.matchId" for SL trains?
There are no guarantees for the matchId field, and it may change without prior warning, since this is a generated id. We recommend therefore against using it in critical applications, but it could work at your own risk if you just want to link it with realtime data from for example Trafikverket to show delays.
Rregards,
Bert
Since matchId can't be relied on, it creates a problem for ut at Vy. We need to have the Trafikverket train number in the response to be able to link it with realtime data from Trafikverket. Because we now get the line number for SL trains instead of the Trafikverket number we are currently unable to show realtime data for SL trains. Is it possible for you to add a field in "leg.product" in the response that always contains the Trafikverket number?
If you wish to obtain train delays based on the trafikverket train number, the Trafikverket Open API may be a better fit for you. https://www.trafiklab.se/api/trafiklab-apis/trafikverket/
Otherwise you could identify trips by line number, direction, departure stop and scheduled departure time, which is a unique combination.
Regards,
Bert
We already have a system in place to obtain realtime information based on the Trafikverket train number. So for us to be able to enhance the data we receive from you with realtime information, using our system, we need the response to include the Trafikverket train number.
And, if I have understood correctly, this number is included in the response from you as the "leg.product.num" field for all trains expect SL trains (where the field instead represents the line number). Which is why I'm wondering if it is possible to always include it as a separate field, since it already appears you have the data. Not only would this be tremendous help for us, but it would help us know whether or not the "leg.product.num" represents Trafikverkets train number or the line number.
It is currently not possible to include this information.
Since you already have the train number, station, scheduled departure time and direction, you could use those for matching Trafikverket data to Resrobot data.
leg.product.num represent the line number shown to the traveller. Since trains typically do not have a line number but instead show a train number on traveler-facing information boards, the train number is shown there for trains, with an exception for SL which announces their trains by line number.
Regards,
Bert
I understand. Thank you for your help and explanation! I'll see if I can find a different solution based on your suggestions.