TSW WebSocket API

This is not a standalone mod but a dependency for third-party applications

This mod adds a powerful websocket server (uWebSockets) to the game.

Developers of external applications can use this to obtain data from the game. The basic idea was developed for an external Ebula system, but I would like to create a central API for all external applications. The existing endpoints are gradually being expanded.

If you would like the websocket server to expose more data, please feel free to contact me. I will then try to provide the requested data.

Please intall the dependency (UE4SS) before installing this mod.

Important: This is a beta release of the mod. If you have any problems or suggestions for improvement, please use the comment function. You can also contact me via Discord.

How to use

After installing the game will expose a websocket server at localhost:9187.
The developer manual is available here: https://vanlueckn.github.io/tsw-websocket-docs

Known issues

  • Currently the port is hardoced to 9187

Roadmap

  • Add more useful data to expose via the server
  • Add configurable interval on subscription
Changelog
  • Version 0.1: Initial release
  • Version 0.2: Added execution of console commands
  • Version 0.3: Added individual subscription intervals and fixed a crash

Requirements

Needed for loading C++ and Lua Mods

Installation Instructions

The downloaded ZIP archive must be unpacked into the folder \WindowsNoEditor\TS2Prototype\Binaries\Win64\ue4ss\Mods.

If you are playing on XBox Games the Mods folder location may differ.

Tags: api code server ue4ss websocket

Files

WebsocketModv0.3.zip 454 KB · Added 16 Jan 2025 · Downloaded 107×

Version 0.3

Previously uploaded files have been downloaded 27 times before being withdrawn.

Comments

Avatar of OpenMinded
OpenMinded 14 Jan 2025

Thanks, Luex! This will open up so many possibilities, I am sure it will be put to use very soon:-)

Avatar of Dinnox
Dinnox 19 Jan 2025

Thanks !
I know a third party app developer that will be interested by this !
This mod would actually help integrate their app core features in TSW (TSW is not fully integrated yet) so it could work as well as it works for TSC.
It definitely opens a new door for new mods :)

Avatar of Liam
Liam 9 Feb 2025

Threw together a web app which uses this mod to track the current train onto Openrailwaymap if anyone finds it useful
https://www.reddit.com/r/trainsimworld/comments/1ilps67/openrailwaymap_train_tracking_app/

Avatar of Luex
Luex 10 Feb 2025

Nice. If you want any new features or if there are any problems, just let me know.

Avatar of Liam
Liam 15 Feb 2025

@Luex I did notice the mod itself is somewhat unstable; for example any time I disconnect the client while the game is running it crashes

Avatar of toast6833
toast6833 13 Feb 2025

Would it be possible to include scenario objectives, like next stop?

Avatar of Luex
Luex 13 Feb 2025

Hi, i will have a look at this

Avatar of Nina
Nina 19 Feb 2025

Hi,
this project seems super cool. I am playing with the idea of connecting up real displays to TSW, so for example a destination board shows what youre driving in the game.
Would it be possible to get all infos related to services (headcode, service number, type, station stops, destination, times, etc) out of the API? I mean, taking it to the extreme, we could create a thing similar to ZUSI Display.

Cheers for the mod!

Avatar of bb00
bb00 11 Mar 2025

Hey, are you still working on this mod?

Add a comment

If you wish to leave a comment, please log in .

About this mod

Created
14 Jan 2025
Updated
16 Jan 2025
Game
Train Sim World
Type of content
Other
Train Sim World compatibility
Train Sim World 5