OK, I made some progress
The software I use - FHEM - has a module called HTTPMOD that allows a quite fine tuned connection to any physical device offering an interface via http, be it REST or just plain web pages.
The first thing I do is to submit a POST request to http://IP-Address:8080/api/v1/connect?token=$sid
where “$sid” is replaced by a previous token. The logical device is named SnapMaker.TEST, hence in my home system I can either type “set SnapMaker.TEST connect”, or push the appropriate button.
The token I have included into this POST request apparently allows to reconnect without the unnecessary confirmation question at the touchscreen.
The “connect” command receives a new token from the SnapMaker, which is again placed into the variable $sid. (Footnote: The whole FHEM system is programmed in Perl).
When the connection event is registered, a loop starts which calls
get SnapMaker.TEST enclosure,
get SnapMaker.TEST status
every 5 seconds. As long as I do this, the connection remains stable and I get regular updates.
These two FHEM commands issue GET requests to the two URL
http://IP-Address:8080/api/v1/enclosure?token=$sid
http://IP-Address:8080/api/v1/status?token=$sid
When I stop the loop, the connection is going down, and the HTTP body received is just “The Machine is not connected yet.” By issueing a “set SnapMaker.TEST connect” I reconnect properly, and the data keeps arriving again.
In the next step (give me some days…) I will make this a little more intelligent, like e.g. binding the loop to the power switch of the SnapMaker (to be precise: This is done by a Shelly WLAN-operated switch), implementing an automatic reconnect etc.
Also, I have to integrate this with the Octoprint module in FHEM, such that I do not need several FHEM devices for one machine. But the door is open now.