how?: Interrogate print status from command line


#1

Is it possible to interrogate octoprint from the command line to get print status details and similar information?
I want to be able to write bash/python/whatever scripts to pull simple statistics from the active octoprint instance...so it MUST be from the command prompt. ... wget/curl if necessary.


#2

Try the CLI:

$ octoprint client --help
Usage: octoprint client [OPTIONS] COMMAND [ARGS]...

  Basic API client.

Options:
  -a, --apikey TEXT
  -h, --host TEXT
  -p, --port INTEGER
  --httpuser TEXT
  --httppass TEXT
  --https
  --prefix TEXT
  --help              Show this message and exit.

Commands:
  command         Sends a JSON command to the specified server...
  delete          Sends a DELETE request to the specified...
  get             Performs a GET request against the specified...
  listen
  patch_json      PATCHes JSON data to the specified server...
  post_from_file  POSTs JSON data to the specified server path,...
  post_json       POSTs JSON data to the specified server path.
  upload          Uploads the specified file to the specified...

Or use curl with the API.


Can I use octoprint server as library in my python tool
#3

Thank you. This answers one part of my question. And this answers the rest.
http://docs.octoprint.org/en/master/api/job.html#retrieve-information-about-the-current-job