I want to get the same data as requested in this post.
However the post is closed and i wonder if either the original owner of the post or anyone else has some example code to get the data through API? I'm able to get temperature, but not coordinates which is essential for my analysis goals.
Coordinates of the nozzle is going to be tricky because you have to send a gcode command to request position and I don't think any of the API endpoints will return the response of that command. As foosel stated if you want real time data connecting a websocket connection is really the only way to get anything close to realtime, and even then positioning is questionable due to buffers, etc.
Aha, i don't need realtime as i can do the analysis after the print is done. I have been looking into the websocket, but i'm a mechanical engineering student with limited coding experience. So even if there was a way to save the "approximate tool position" along with temperature it would be enough
I was not able to fix this but i found a shitty workaround by using python to push gcode "M114" to the printer through rest API every second or so and then saving the serial.log file.
By filtering this file i was able to get a fairly well resolution on the coordinate points with timestamps to coorelate to my other sensor data.
Since it doesnt seem like this will be a hook in the future either, i will use time of fligt sensors for the xyz position in the future to avoid bothering the octoprint sever at all.
be careful with serial.log being enabled all the time. it can fill up fast and all of a sudden you don't know what you can't upload anything.