Let Octoprint pause/resume with Python script


Searched this forum, could not find it, but it must be easy.

I want to pause/resume/stop/cancel/forwardgcode Octoprint through an external script.
The moment when I send this command could be anything, from a fire-alarm to a doorjam, or any switch that would be triggered by any of the GPIO's which on it's turn could come from an Arduino etc...

Is there a simple way to send Octoprint one of those commands? To Octoprint, not to the printer.

thanks for any answer

You want the OctoPrint API - REST API — OctoPrint documentation

Maybe specifically Job operations — OctoPrint documentation. In Python calling this API is quite easy, using the requests module. You'll need the API key, correct headers and content type etc. but this is all described under the general section. Come back if you have any more questions :slightly_smiling_face:

Thanks. All what I needed! (for now)

1 Like