Accessing live gcode with Moonraker

Hey there, from my research and understanding there is a way to access the live used gcode with the Moonraker API. But with my limited skills in software development, I couldn’t get a script to run. AI didn’t help either.
My attempt was to set up the websocket connection:

import websocket
url = the specific websocket url

def ws_error(ws, error):
    """Callback function to handle WebSocket errors."""
    print("Error:", error)

def ws_open(ws):
     print("WebSocket connected")

def main():
     ws = websocket.WebsocketApp(url,ws_error)
     ws.on_open = ws_open

with a setup like this, the Status returns: Error: Handshake status 200 OK

To access the gcode I would use the given example in the Moonraker docs.
https://moonraker.readthedocs.io/en/latest/web_api/
https://moonraker.readthedocs.io/en/latest/printer_objects/

If you have any other ideas on how to solve this please let me know.

Hi,
I used this method to build a bot for the keybase messenger application.
To do so i based a lot of my code upon : GitHub - Arksine/moontest: A (very) basic test client for Moonraker's API

Does this seems to be what you are searching for ?

Looks promising, I’ll try it, thanks.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.