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...
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 http://localhost:31270/list http://localhost:31270/info These give you insight into available nodes and endpoints, great starting points for exploring.
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!
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
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!
I've been trying to figure out what is possible through the API, and to write proper API documentation for it. To be able to inspect all possible available information on the API I've also written an inspector that allows for inspecting all possible values and controlling some that are writable. Viewing all nodes and their endpoints works. Continuously fetching a endpoint's value also works. Setting writable endpoints also works. I've even been able to setup some rudimentary controls for PushButtonControls and IrregularLevelControls. Which is the vast majority of the nodes with writable endpoints. I've not been able to setup the subscription. I can add a Path to a subscription. But when fetching the information on that subscription, no data is returned. For actual controlling the game it works well enough, but listening for values would definitionally be preferred to run over Server Sent Events of even Websockets.
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
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 That being said, if we can only get the lat/long of the player that’s going to be a pretty empty map
Just in case it was missed by anyone, there is now an official documentation on the API: https://forums.dovetailgames.com/attachments/tsw-external-interface-api-1-5-1-pdf.203411/ Question to DTG (DTG Matt DTG Harry ), would it make sense to open an "official" API feedback thread?! Sorry if I have missed it but I could not finde one. Or is there any other way to give feedback and / or whishes for future endpoints that could be used?!
Wow, this is a pretty useful API! I just knocked up a quick demo to see if it would show all the trains in my current Preston-Carlisle session... hey presto... it's following me all the way to Carlisle now. Kind of takes the fun out of the drive though, I can see what's coming towards me way in advance now Might be a useful dev tool though I guess. Most likely I'll just use it for route learning though.
Feels like there’s a lot to explore here. Trouble is Birmingham-Crewe is out on Tuesday, and that’s my exploring time all spoken for right there
Anyone had any luck finding things like status of being 'stopped at objective' or 'loading status'. Can't find anything in the track monitor or the HUD. What I'm after is the bit of the hud that displays the 'lock door' message
I've looked and I couldn't find it either, I don't think it's in there yet. Has anybody managed to get values for endpoint names that have a space in them? E.g. VirtualRailDriver/Auto Brake. http://localhost:31270/get/VirtualRailDriver.Reverser works fine, /get/VirtualRailDriver.Auto<Encode space>Brake does not (HTML encoded whitespace, struggling with formatting here), seems like a bit of an oversight to have whitespace in some of these endpoint names?
Try "%20" In C# you can do this: string encodedNodeName = Uri.EscapeDataString("VirtualRailDriver.Auto Brake"); This results in "VirtualRailDriver.Auto%20Brake" I have not used it with spaces, but with endpoint having "/" in it ""AWS/TPWS" but it should also escape spaces. Becomes "AWS%2FTPWS"
Hi all, I am an amateur user of Arduino projects and I would like to create custom and mechanical controls for TSW using digital an analog enters. I understand the Api works with HTTP commands. Does it mean that I could send from the Arduino program those commands to be readed by the Api? If yes, how I can set the comm between the Arduino card and the PC? Serial? Ethernet? Sorry for my ignorance about these things... Thanks in advance.
The software on the Arduino would be making HTTP requests to the game, so the Arduino has to be hooked up to the same LAN either via physical Ethernet or WiFi.
I have been using processing as an interface between an arduino and the game. Processing makes the request to the game and then sends the result via serial over usb to an arduino with an lcd display. Just because I don't have an arduino or similar to hand that had network capability.