[MOD/API] X4RestServer - External http API

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
Alia5
Posts: 43
Joined: Tue, 10. Apr 07, 22:32
x4

[MOD/API] X4RestServer - External http API

Post by Alia5 »

X4 Rest Server

X4 Rest Server aims to provide an external http/rest API for the game

This is mainly focused on other developers, to create external tools that provide extra functionality for second screens or similar.

It should work on Windows and Linux

The project should be primarily focused on data-out, not for interacting with the game from the far, or even cheating.
All without getting "modified"
We'll see how things shake out, however...

It works by loading a shared-library (.dll/.so) into the game.
The mod loads functions from the game, which are exposed via FFI, normally used for lua-scripts managing the game UI, and calls them directly. The results are then sent out as json via an inbuilt http-server

Due to the fact, that most code is generated, almost all endpoints use http-GET requests, even if changing values in the game. (We’ll see how long that stays…)

The project is currently in POC (proof of concept) stage.
A first alpha Release is available below

If you do want to contribute, feel free to check out the Github-Repo

Info / Download

https://alia5.github.io/X4-rest-server/
https://github.com/Alia5/X4-rest-server/releases

Demo:
[ external image ]
(click me)
Last edited by Alia5 on Thu, 7. May 20, 00:23, edited 6 times in total.
User avatar
Alia5
Posts: 43
Joined: Tue, 10. Apr 07, 22:32
x4

Re: [MOD/API] X4RestServer - External http API

Post by Alia5 »

07.05.2020
0.1.1
- First Linux POC

04.05.2020
0.1.0
- First alpha release

26.04.2020
- First public announcement / POC
Last edited by Alia5 on Thu, 7. May 20, 00:24, edited 4 times in total.
Mycu
Posts: 412
Joined: Fri, 28. Sep 12, 08:30
x4

Re: [MOD/API][POC] X4RestServer - External http API

Post by Mycu »

See a great oportunity for a second monitor info app, or even for example some galaxy news feed app fetching data from https://forum.egosoft.com/viewtopic.php?f=181&t=426035
Hoping that this project will get more attention.
X3 AP 3.1 + XRM
X3 AP 3.1 + LU
Phiolin
Posts: 158
Joined: Wed, 26. May 04, 08:49
x4

Re: [MOD/API][POC] X4RestServer - External http API

Post by Phiolin »

This sounds really good.
Could potentially also be used to build a "real" map of the current in-game sectors & economy with stations, trade offers etc being browsable in a GUI on a secondary PC or monitor, or to import existing station layouts into a station planner... there's great potential I guess as tools similar to what exists for Elite Dangerous could be build for example to allow better handling and understanding of your current ingame universe.
Praeses
Posts: 2
Joined: Sun, 9. Dec 18, 09:24
x4

Re: [MOD/API][POC] X4RestServer - External http API

Post by Praeses »

This is really, really awesome!! I cannot wait to see what cool things comes out of this.
Praeses
Posts: 2
Joined: Sun, 9. Dec 18, 09:24
x4

Re: [MOD/API][POC] X4RestServer - External http API

Post by Praeses »

From a layman perspective, what sort of information can it pull?
And how often can it update the information?

While I do not have the technical expertise to help with coding, I'm a designer and I'd love to design a use case for such a tool.
User avatar
Alia5
Posts: 43
Joined: Tue, 10. Apr 07, 22:32
x4

Re: [MOD/API][POC] X4RestServer - External http API

Post by Alia5 »

Praeses wrote: Fri, 1. May 20, 00:58 From a layman perspective, what sort of information can it pull?
Pretty much everything that the ingame UI can show you.
Praeses wrote: Fri, 1. May 20, 00:58 And how often can it update the information?
Realtime.

Dev note: In the first iteration this is done via polling. At a later stage it is planned to look at how feasible it is to implement ServerSentEvents (SSE)
Max Bain
Posts: 1463
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [MOD/API][POC] X4RestServer - External http API

Post by Max Bain »

Would it be possible (maybe in different but similar version) to interact with the game from outside?

What I have in mind is like a venture system where two players connect to each other IF they have the same mods and share their IP, so you can invade or help each other. For me this would put X4 on a completely new level.
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link
User avatar
Alia5
Posts: 43
Joined: Tue, 10. Apr 07, 22:32
x4

Re: [MOD/API][POC] X4RestServer - External http API

Post by Alia5 »

Interacting with the game will definitely be implemented in a later version, but not in the way you imagined.

There are 1200 functions exposed that can probably all be used and I haven't looked through all of them, though.
teleportationwars
Posts: 158
Joined: Fri, 12. Jul 19, 14:03

Re: [MOD/API][POC] X4RestServer - External http API

Post by teleportationwars »

Max Bain wrote: Fri, 1. May 20, 15:50 Would it be possible (maybe in different but similar version) to interact with the game from outside?

What I have in mind is like a venture system where two players connect to each other IF they have the same mods and share their IP, so you can invade or help each other. For me this would put X4 on a completely new level.
This is already possible with the amount of progress SirNukes has made with his server. Someone just needs to spend the time making all of it.
Max Bain
Posts: 1463
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [MOD/API][POC] X4RestServer - External http API

Post by Max Bain »

teleportationwars wrote: Fri, 1. May 20, 19:13
Max Bain wrote: Fri, 1. May 20, 15:50 Would it be possible (maybe in different but similar version) to interact with the game from outside?

What I have in mind is like a venture system where two players connect to each other IF they have the same mods and share their IP, so you can invade or help each other. For me this would put X4 on a completely new level.
This is already possible with the amount of progress SirNukes has made with his server. Someone just needs to spend the time making all of it.
That would be really awesome I think and I think many ppl would like to play a bit together this way (and with mods).
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link
User avatar
Alia5
Posts: 43
Joined: Tue, 10. Apr 07, 22:32
x4

Re: [MOD/API][POC] X4RestServer - External http API

Post by Alia5 »

The first public alpha was just released.

https://alia5.github.io/X4-rest-server/
tomchk
Posts: 1294
Joined: Mon, 26. Jan 15, 19:55
x4

Re: [MOD/API] X4RestServer - External http API

Post by tomchk »

Awesome potential here! I've been wondering if the developers would themselves give us some read-only interface, but they may not have time.
Care to see what I've been creating? https://www.youtube.com/user/ytubrute
User avatar
Alia5
Posts: 43
Joined: Tue, 10. Apr 07, 22:32
x4

Re: [MOD/API] X4RestServer - External http API

Post by Alia5 »

I've just built a first POC for Linux!

It should be exactly the same as on Windows, functionality-wise.

Although, I haven't really tested this yet, as I cannot fully run X4 in my VM, and I currently don't currently have Linux installed on bare-metal.

https://github.com/Alia5/X4-rest-server ... /tag/0.1.1

Of course, one can build him-/herself
JasonX2000
Posts: 208
Joined: Thu, 2. Oct 14, 15:04
x4

Re: [MOD/API] X4RestServer - External http API

Post by JasonX2000 »

I hope your work will get well.
I can see something like websites with satistic overviews, etc.
Rezoken
Posts: 13
Joined: Sat, 6. Feb 16, 08:54
x4

Re: [MOD/API] X4RestServer - External http API

Post by Rezoken »

Do we have any indication from the X4 Devs that the DLL injection is not going to possibly be flagged through Steam or anything like that?
ShoC
Posts: 693
Joined: Sun, 8. Feb 04, 15:06
x4

Re: [MOD/API] X4RestServer - External http API

Post by ShoC »

Wow this is exciting !!

You have given me a project. (If I get a chance)

Make a website for displaying all the data, I'd look at logging account finance and storing that to an SQL lite data-base and use Google API to make charts showing asset changes over time periods chosen.

What would be interesting is getting global averages for all product prices and seeing how they change over time.

Man this is awesome!
they have had almost 1000 years to terraform Aldrin, why are they all still sitting around a giant rock?

Catra wrote:
because you cant terraform a rock.
Exi
Posts: 24
Joined: Tue, 2. Dec 03, 22:20
x3tc

Re: [MOD/API] X4RestServer - External http API

Post by Exi »

Reading this literally made me jump back into the X universe, after a very long break. Years ago I've made a mod for X3 TC/AP which displayed ingame information on the Saitek X52 Pro's display, and also used the LEDs on the controller for various feedback. Your work could make it possible to port this to X4 now, and it could be even better than the original due to the possibilities in this API. I've waited out with X4 for quite long, but this was a trigger.
So I'm looking forward to see more of your work, and a big thank your for all the time invested in this.
kuertee
EGOSOFT
EGOSOFT
Posts: 817
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [MOD/API] X4RestServer - External http API

Post by kuertee »

bookmarked :)
User avatar
beko
Posts: 80
Joined: Thu, 11. Jun 20, 21:14
x4

Re: [MOD/API] X4RestServer - External http API

Post by beko »

I want to report a bug: This project is way to exciting!

I got it running on Linux
Spoiler
Show
and may be aroused :o

Return to “X4: Foundations - Scripts and Modding”