PC Api Documentation

Discussion in 'TSW General Discussion' started by lawn.chairs, Sep 19, 2025 at 3:52 PM.

  1. lawn.chairs

    lawn.chairs Member

    Joined:
    Aug 8, 2021
    Messages:
    48
    Likes Received:
    49
    Anyone have any API docs? Would love to finally be able to write my own controller inputs. I'm assuming its some C++ tie-in to unreal but I'm definitely not familiar enough with unreal's architecture...
     
  2. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    172
    Likes Received:
    157
    I don't think API documentation is available yet but this is a good startpoint:

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

    Start by checking these endpoints using f.e Postman, don't forget to add the api key in the header called "DTGCommKey".
    When you activate the API by adding the -HTTPAPI launch parameter in Steam, you can find the api key in you user profile under Documents\My Games\TrainSimWorld5\Saved\Config\CommAPIKey.txt
    These give you insight into available nodes and endpoints, great starting points for exploring.
     
    • Helpful Helpful x 3
    • Like Like x 2
  3. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    172
    Likes Received:
    157
    While we wait for the official Train Sim World API documentation, I’ve compiled an unofficial reference PDF based on how ThirdRails uses the API.
    It includes practical examples of API usage and should be helpful if you’re exploring implementation details.

    If you’re interested in working with it in C#, I’m happy to share my client code to help you get started.

    You can download the unofficial API documentation at ThirdRails.org: https://thirdrails.org/Downloads/TSW_API_Unofficial_Documentation.pdf

    Hopefully this can help anybody out there!
     
    • Like Like x 3
    • Helpful Helpful x 1
  4. lawn.chairs

    lawn.chairs Member

    Joined:
    Aug 8, 2021
    Messages:
    48
    Likes Received:
    49
    Awesome. The main control goodness is definitely in setFeatureStatus. And because this is HTTP, I don't need the C# code -- I just figured that this was some UE4 dll tie-in under the hood. (It still might be, but if so then TSW has done the work of abstracting it.)

    This isn't the world's best use case for an HTTP implementation (a websocket layer would absolutely shine here) but async requests ought to get the job done given the absolute minimal latency of local devices.

    Nice work, much appreciated
     
  5. BeenTrain

    BeenTrain Active Member

    Joined:
    Dec 10, 2016
    Messages:
    172
    Likes Received:
    157
    Yeah I see what you mean. But I must say that polling the API works fine for ThirdRails. On localhost there’s really no noticeable latency, even when polling multiple times per second for sessions that run over an hour.
    It’s great that DTG is making this possible it is really fun to build on!
     
  6. lawn.chairs

    lawn.chairs Member

    Joined:
    Aug 8, 2021
    Messages:
    48
    Likes Received:
    49
    darn right. so many great project ideas floating through my head.

    now i'm really gonna need to buy a 3d printer and figure out cad. oh no, woe is me
     
  7. pogodoyle#7387

    pogodoyle#7387 Well-Known Member

    Joined:
    Aug 21, 2021
    Messages:
    247
    Likes Received:
    655
    This looks like an interesting API … already thinking of quick hack for my TrainMapper app to show the live positions of everything in the game, just to see how it looks! In theory it’s just replacing the live NR feed with an adapter off the back of this API :cool:

    That being said, if we can only get the lat/long of the player that’s going to be a pretty empty map :D
     
    Last edited: Sep 22, 2025 at 11:36 PM

Share This Page