[MOD/API] X4RestServer - External http API

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

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

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

[MOD/API] X4RestServer - External http API

Post by Alia5 » Sun, 26. Apr 20, 02:02

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: 42
Joined: Tue, 10. Apr 07, 22:32
x4

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

Post by Alia5 » Sun, 26. Apr 20, 02:02

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: 410
Joined: Fri, 28. Sep 12, 08:30
x4

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

Post by Mycu » Sun, 26. Apr 20, 10:14

See a great oportunity for a second monitor info app, or even for example some galaxy news feed app fetching data from 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 » Sun, 26. Apr 20, 10:45

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 » Fri, 1. May 20, 00:19

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 » Fri, 1. May 20, 00:58

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: 42
Joined: Tue, 10. Apr 07, 22:32
x4

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

Post by Alia5 » Fri, 1. May 20, 14:44

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: 1461
Joined: Wed, 27. Jun 18, 19:05
x3ap

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

Post by Max Bain » 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.
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: 42
Joined: Tue, 10. Apr 07, 22:32
x4

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

Post by Alia5 » Fri, 1. May 20, 16:56

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 » 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.

Max Bain
Posts: 1461
Joined: Wed, 27. Jun 18, 19:05
x3ap

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

Post by Max Bain » Fri, 1. May 20, 19:54

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: 42
Joined: Tue, 10. Apr 07, 22:32
x4

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

Post by Alia5 » Tue, 5. May 20, 00:01

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 » Tue, 5. May 20, 16:58

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: 42
Joined: Tue, 10. Apr 07, 22:32
x4

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

Post by Alia5 » Thu, 7. May 20, 00:06

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: 153
Joined: Thu, 2. Oct 14, 15:04
x4

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

Post by JasonX2000 » Thu, 7. May 20, 21:03

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 » Tue, 12. May 20, 17:34

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 » Wed, 13. May 20, 09:58

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 » Wed, 21. Oct 20, 20:17

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: 789
Joined: Sun, 14. Dec 03, 13:05
x4

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

Post by kuertee » Thu, 22. Oct 20, 13:55

bookmarked :)
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

User avatar
beko
Posts: 53
Joined: Thu, 11. Jun 20, 21:14
x4

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

Post by beko » Sat, 1. May 21, 21:29

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

Post Reply

Return to “X4: Foundations - Scripts and Modding”