This example show how to use the Moonraker Client API per Python.
A complete description of the Moonraker Client API can be found here
The ClientAPI can be used in two different ways:
- per HTTP Requests
- per Websocket
- Websocket uses JSON RPC
The posted examples using the websocket-client python library. This library has to be installed to use this examples.
This example shows how to use the MoonrakerAPI per HTTP requests
This example show how to use the websocket in a simple way.
- Connect to Websocket
- Request Data
- Disconnect from Websocket
This example uses the more complex websocketapp from the websocket-client library.
- Connect to Websocket
- Request Data
- Stay connected
- Status Updates published from Moonraker are also shown in this example
Show how to subscribe to printer objects. The subscribed objects were periodically send on the websocket from moonraker to the script.
Warning: Only values that have changed are transmitted.
Query some printer objects and subsscribe afterwards and update global variables with data which was delivered periodically.