Mirar
August 22, 2021, 11:58am
1
I've been searching up and down, but I can't find the REST API to get the terminal data for the communication with the printer? The UI obviously gets this somehow, but how do I get access to it?
I'm probably just searching with the wrong keywords... anyone?
I want the same thing as being output in the UI Terminal.
You'll need to use the websocket to access this data.
https://docs.octoprint.org/en/master/api/push.html
Depending on the programming language you are trying to use, I have a few examples I can point to.
1 Like
Can you share any python example
There is a Python example in this simple OctoPrint client here:
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
import json
import time
import requests
import websocket
def build_base_url(
https=False, httpuser=None, httppass=None, host=None, port=None, prefix=None
):
protocol = "https" if https else "http"
httpauth = f"{httpuser}:{httppass}@" if httpuser and httppass else ""
host = host if host else "127.0.0.1"
port = f":{port}" if port else ":5000"
prefix = prefix if prefix else ""
return f"{protocol}://{httpauth}{host}{port}{prefix}"
This file has been truncated. show original