PC Thirdrails Live Map Tracker Now Supports Train Sim World 5

Discussion in 'TSW General Discussion' started by BeenTrain, Oct 21, 2024.

  1. Princess Entrapta

    Princess Entrapta Well-Known Member

    Joined:
    Jul 23, 2021
    Messages:
    3,116
    Likes Received:
    4,052
    If your email has issues, the forum also has direct user to user messages, just FYI.
     
    • Like Like x 2
  2. Volvo B10M

    Volvo B10M Active Member

    Joined:
    Apr 21, 2022
    Messages:
    342
    Likes Received:
    49
    I forgot DM was available on here, thanks for reminding me.
     
    • Like Like x 1
  3. protonmw

    protonmw Active Member

    Joined:
    Mar 18, 2022
    Messages:
    190
    Likes Received:
    149
    BeenTrain are you using the httpapi? Is there any further information regarding the api somewhere available? More endpoints perhaps?
     
  4. Bradmac

    Bradmac Member

    Joined:
    Jul 28, 2020
    Messages:
    77
    Likes Received:
    40
    I'm getting a Thirdrails crash when trying to do a DB service:
    * Start Service
    * Europe
    * Search for services from a location - eg Köln Hbf
    * List of services appears
    * Click on service to see schedule - Thirdrails crash!

    Anyone else having this problem?
     
  5. OpenMinded

    OpenMinded Well-Known Member

    Joined:
    Feb 10, 2021
    Messages:
    1,348
    Likes Received:
    2,308
    BeenTrain , what kind of insight do you have into the capabilities of this API? Obviously there is no official documentation about it, however, we are also experimenting with it and are looking specifically for a time read out (local, UTC, or whatever, could theoretically simply be a timer which run synchronously with TSW time progression), which we can not find. Have you any more information about this, by any chance?!
     
  6. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    175
    Likes Received:
    157
    protonmw OpenMinded
    Yes, I’d be happy to share what I know about the API!

    I’m currently on vacation, so a full deep dive is a bit tricky at the moment, but you can already explore quite a bit yourself.

    The API runs on http://localhost:31270/.

    Start by checking these endpoints using f.e Postman, dont forget to add the api key in the header called "DTGCommKey"
    These give you insight into available nodes and endpoints, great starting points for exploring.

    OpenMinded you probably need the TimeOfDay node:../get/TimeOfDay

    If you’re using C#, you can also take a look at the TSWData.dll included in the ThirdRails setup. It exposes a TSWDataService that wraps the parts of the API used in ThirdRails (functions, models, etc.).

    I do have plans to open-source it in some form soon.

    Hope this helps! I’ll be back by the end of next week, so I can provide more info or examples if needed, instantly forgot the details on the beach :D:cool:
     
    Last edited: Jul 4, 2025
    • Like Like x 4
    • Helpful Helpful x 2
  7. OpenMinded

    OpenMinded Well-Known Member

    Joined:
    Feb 10, 2021
    Messages:
    1,348
    Likes Received:
    2,308
    Helps a great deal already, many thanks!

    Have a great remaining holiday, then:cool:
     
    • Like Like x 1
  8. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    175
    Likes Received:
    157
    Are you using the latest version (9.0.0.4)?
    There was a crash related to the DB service in an earlier version which I’ve since fixed.

    I saw some DB real drive services show up on the radar recently, so it looks like it’s working. Not able to check myself right now.
     
  9. Bradmac

    Bradmac Member

    Joined:
    Jul 28, 2020
    Messages:
    77
    Likes Received:
    40
    Ahh. I was using version 9.0.0.0. I didn't realise it was not the latest version as it said it was up to date when I pressed "check for new version."

    Anyway it's fixed now. Thanks ;)
     
    • Like Like x 1
  10. JGW1977

    JGW1977 New Member

    Joined:
    Aug 7, 2024
    Messages:
    5
    Likes Received:
    6
    Hi maybe I am missing something but I have attempted to follow an 'ad hoc' timetable today. I run RW Enhancer too and created a quick drive and stops in it then loaded up the game through it, and the ThirdRails map after that. I noticed that the timetable clock on the TR map app was ticking through seconds at a faster rate than they were on TS itself. This was meaning it was saying I was behind time repeatedly. Any idea what I am doing wrong? Thanks!
     
  11. madleech

    madleech New Member

    Joined:
    Jan 29, 2025
    Messages:
    1
    Likes Received:
    0
    You can also set API parameters by writing to a writable "Node", e.g.:
    Code:
    curl -H "DTGCommKey: ..." http://127.0.0.1:31270/set/CurrentFormation/0/Reverser.InputValue?value=1
    The writable nodes can be explored using the "list" APIs, and looking at the returned nodes. Most are read-only, however "InputValue" and "Interacting" are usually writable.
     
  12. protonmw

    protonmw Active Member

    Joined:
    Mar 18, 2022
    Messages:
    190
    Likes Received:
    149
    Thank you very much for your help! I was able to get it working.
    Were you able to set a weather value? I tried a lot but always resume errors from the server.
     
  13. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    175
    Likes Received:
    157
    You are doing nothing wrong. You should ignore the TSC time and execute the timetable using ThirdRails HUD. This makes it most flexible because you could drive a night service in daylight if you like.

    In TSW its the other way around where you can ignore ThirdRails timings, this is because every TSW scenario has a timetable. (Check "Follow Simulator's Schedule") Could also be used in TSC which hides ThirdRails timings and timeliness.

    This tutorial explains it in more detail:
    https://www.thirdrails.org/tut_timetabledrides.html
     
    Last edited: Jul 7, 2025
    • Like Like x 1
  14. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    175
    Likes Received:
    157
    Have not played with weather.
    But generaly you must use the HTTP Patch method to set values. For weather it would be something like this:
    Http://localhost:31270/set/WeatherManager.Temperature?Value=15

    Hope this helps!
     
    • Helpful Helpful x 1
  15. OpenMinded

    OpenMinded Well-Known Member

    Joined:
    Feb 10, 2021
    Messages:
    1,348
    Likes Received:
    2,308
    Gave this a little try and it has actually worked:D Thanks so much for your insight!
     
    • Like Like x 1
  16. Winzarten

    Winzarten Well-Known Member

    Joined:
    Jun 27, 2020
    Messages:
    505
    Likes Received:
    983
    As this is turning into the API discussion :D Is there any way to get the currently selected track (doesn't have to be a human readable name, just something that can be used as identification) hidden somewhere in the api?
     
  17. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    175
    Likes Received:
    157
    Yes, you can get track data via the get/DriverAid.TrackData endpoint. I initially used it to calculate track gradient, but later realized that gradient is also available directly via the DriverAid endpoint.

    To give you an idea what it offers, here’s the C# model I use to deserialize the response:

    Code:
        public class TrackDataResponse
        {
            public string Result { get; set; }
            public TrackValues Values { get; set; }
        }
        public class TrackValues
        {
            public LastPlayerPosition LastPlayerPosition { get; set; }
            public List<TrackHeight> TrackHeights { get; set; }
            public List<Station> Stations { get; set; }
            public List<Marker> Markers { get; set; }
        }
        public class TrackHeight
        {
            public double Height { get; set; }
            public double DistanceToHeight { get; set; }
            public bool BTunnelFound { get; set; }
        }
        public class Station
        {
            public string StationName { get; set; }
            public DistanceToStation DistanceToStation { get; set; }
            public double DistanceToStationCM { get; set; }
            public double PlatformLength { get; set; }
            public string MarkerType { get; set; }
            public string MarkerName { get; set; }
        }
    
    
    I found out that Stations and Markers are not always fully populated,they seem to be incomplete or not implemented in every route.

    To get back on the topic ThirdRails :love::o:
    If you're using C#, it's worth checking out the TSWData.dll that comes with the ThirdRails setup. It hides the API behind a service class, so you don’t have to deal with all the technical details.
     
    Last edited: Jul 14, 2025
    • Helpful Helpful x 3
    • Like Like x 2
  18. Princess Entrapta

    Princess Entrapta Well-Known Member

    Joined:
    Jul 23, 2021
    Messages:
    3,116
    Likes Received:
    4,052
    upload_2025-9-18_23-56-54.png

    Small niggle I know, compared to more important functionality, especially with the bing debacle, but last I checked, still not a "he" ;) any chance of a box to tick on the account page? Some kind of small bit of profile customisation might be cool like a short paragraph long blurb, or avatars.
     
    Last edited: Sep 19, 2025
  19. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    175
    Likes Received:
    157
    “the bing debacle” LOL, you make it sound so dramatic :)

    I have no plans to add account options for now. Due to privacy I want to know nothing about you guys and girls except the required stuff.
    But you have a fair point. For now I’ve changed it using a well known railway trick: a neutral section.

    Princess Entrapta did a ride on Train Sim World! Whistle blown - check out the trip

    If you find more gender mix-ups, let me know!
     
    • Helpful Helpful x 1
  20. Princess Entrapta

    Princess Entrapta Well-Known Member

    Joined:
    Jul 23, 2021
    Messages:
    3,116
    Likes Received:
    4,052
    Yep, that works!

    Simplest solutions!
     
    • Like Like x 1
  21. kilt46

    kilt46 Well-Known Member

    Joined:
    Jan 23, 2022
    Messages:
    1,435
    Likes Received:
    732
    Is this capable on TSW6?
     
  22. Winzarten

    Winzarten Well-Known Member

    Joined:
    Jun 27, 2020
    Messages:
    505
    Likes Received:
    983
    Yes, it does work. You just need to copy the 'CommAPIKey.txt' file from the TSW5 config folder (My Documents\My Games\TrainSimWorld5\Saved\Config\) to the TSW 6 config folder (or vice versa).

    So TSW 6 uses the same API key as TSW 5, as it is the TSW 5 'CommAPIKey.txt' file that the app currently reads to get the key.
     
    • Helpful Helpful x 1
  23. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    175
    Likes Received:
    157
    Yes, ThirdRails will support TSW 6!
    I already have version detection built in, but I can’t test it myself yet (waiting for Oct 1).
    If you, or anyone, wants to help test before release, please DM me. I’d love to release it earlier once it’s confirmed working. :)
     
  24. kilt46

    kilt46 Well-Known Member

    Joined:
    Jan 23, 2022
    Messages:
    1,435
    Likes Received:
    732
    I can confirm I have TSW6 running on Thirdrails. I copied the txt file over as recommended and it kicked in. Thx
     
    • Like Like x 1
  25. dave#6810

    dave#6810 New Member

    Joined:
    Sep 22, 2025
    Messages:
    2
    Likes Received:
    0
    Hi, thought I'd test this out. Not working for me on TSW6. I've lauched it with the -HTTPAPI and I can see it's created the txt file that's mentioned above, but ThridRails is giving me the error that the TSW API isn't active.

    No rush.
     
  26. Winzarten

    Winzarten Well-Known Member

    Joined:
    Jun 27, 2020
    Messages:
    505
    Likes Received:
    983
    Copy the generated API key to the TSW 5 config folder. The app currently is looking in the TSW 5 config folder, so it needs to find the correct api key there.

    Also BeenTrain
    The app is amazing, I've been using it for a few years in TSC, and I so missed it in my TSW experience. So glad we finally got an API from DTG and the app works with TSW. :)
     
    Last edited: Sep 27, 2025 at 8:22 AM
    • Like Like x 1
  27. kilt46

    kilt46 Well-Known Member

    Joined:
    Jan 23, 2022
    Messages:
    1,435
    Likes Received:
    732
    Copy the existing API key in the TSW5 folder to your new TSW6 folder
     
  28. dave#6810

    dave#6810 New Member

    Joined:
    Sep 22, 2025
    Messages:
    2
    Likes Received:
    0
    Ah ok, thanks all. All sorted
     
  29. Chuckatron

    Chuckatron New Member

    Joined:
    Monday
    Messages:
    2
    Likes Received:
    1
    This is all extremely helpful, thank you! I'm starting a project that will make use of the API but I'm hitting a problem and I'm wondering if you had any insight.

    My project will involve reading and writing the status of various cab controls. I've done some experimenting with the API, using your super helpful notes, and all seems well.

    My main question is, have you come up with an efficient way of watching for train state updates without constant polling? Looking at the available endpoints, there doesn't seem to be any passive way of receiving updates. I'm wanting to catch short lived events, such as receiving the guard signal bell, and I'm suspecting polling will be very error prone as it could miss the brief moment when, for example on the 387, the SignalBell_R value is true.

    Taking into account the main functionality of ThirdRails, and looking at your TSWDataService, you're tracking the train location, so I'm wondering how you're achieving that. I'm hoping you've come up with some way of receiving updates without polling, but am suspecting the limitations of the API are unsurmountable.

    I'll be very grateful for any help you can give, thank you!
     
  30. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    175
    Likes Received:
    157
    Glad you found the info useful!
    The TSW API is REST-based, so unlike a WebSocket API you can’t subscribe directly to events happening in the sim.
    In ThirdRails I currently poll every second with 4–5 requests (Lat/Lon, Speed, Gradient, AWS state). Because it’s all on localhost, there’s no noticeable latency, even during multi-hour runs.
    I recently learned about Subscriptions in the API, with that you can bundle several endpoints into one call. You first subscribe the endpoints you want, and then a single request to that subscription returns all their data at once.
    The current polling setup in ThirdRails runs smoothly, but I’ll be refactoring to use subscriptions to make it even smoother.

    So to answer your question: polling is your only choice, but it’s unlikely to be a problem.
     
  31. Chuckatron

    Chuckatron New Member

    Joined:
    Monday
    Messages:
    2
    Likes Received:
    1
    Thank you for that, very helpful indeed!

    Yes, a WebSocket API would have been lovely, maybe one day...

    I've done some experiments and response times seem to be in the 50ms range, so that should enable me to poll regularly if the need arises, it's good to know you've not encountered any problems.

    Yes, I'd spotted subscriptions listed in the /info response and have experimented with them. It occurred to me it would be a convenient way of easily grouping all the various data I need for a specific class of train, since the nodes seem to be known by different names from one class to another.

    Many thanks again for your help, I'm very grateful.
     
    • Like Like x 1
  32. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    175
    Likes Received:
    157
    For those interested: ThirdRails 9.1 is out!
    Now with auto TSW version detection, so no more swapping API keys between 5 and 6. (and 7,8,9 etc ;))
    Grab your free copy here: https://thirdrails.org/downloads.html
     

Share This Page