From ac648cefcff7ec529d6b76eae3d3fe888b9bfe23 Mon Sep 17 00:00:00 2001 From: Arksine Date: Wed, 30 Sep 2020 18:03:25 -0400 Subject: [PATCH] docs: Add new endpints to API documention Signed-off-by: Eric Callahan --- docs/api_changes.md | 6 +++++ docs/web_api.md | 53 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/docs/api_changes.md b/docs/api_changes.md index da2a678..a02bcf3 100644 --- a/docs/api_changes.md +++ b/docs/api_changes.md @@ -1,6 +1,12 @@ This document keeps a record of all changes to Moonraker's remote facing APIs. +### September 30th 2020 +- Two new endpoints have been added: + - `GET /server/info` (`server.info`) + - `GET /server/gcode_store` (`server.gcode_store`) + See web_api.md for details on their usage. + ### September 7th 2020 - A new websocket API has been added, `server.files.delete_file`: ``` diff --git a/docs/web_api.md b/docs/web_api.md index e559834..f0eb7af 100644 --- a/docs/web_api.md +++ b/docs/web_api.md @@ -166,8 +166,8 @@ that uses promises to return responses and errors (see json-rcp.js). ...} } ``` - Note that Moonraker's current behavior is maintain a superset of all client - subscriptions, thus you may received data for objects that you did not + Note that Moonraker's current behavior is to maintain a superset of all + subscriptions, thus you may receive updates for objects that you did not request. This behavior is subject to change in the future (where each client receives only the subscriptions it requested). @@ -192,6 +192,29 @@ that uses promises to return responses and errors (see json-rcp.js). z: "open"} ``` +### Query Server Info +- HTTP command:\ + `GET /server/info` + +- Websocket command: + `{jsonrpc: "2.0", method: "server.info", id: }` + +- Returns:\ + An object containing the server's state, structured as follows: + +```json + { + klippy_connected: , + klippy_state: , + plugins: [] + } +``` + Note that `klippy_state` will match the `state` value received from + `/printer/info`. The `klippy_connected` item tracks the state of the + connection to Klippy. The `plugins` key will return a list of all + enabled plugins. This can be used by clients to check if an optional + plugin is available. + ### Fetch stored temperature data - HTTP command:\ `GET /server/temperature_store` @@ -206,6 +229,32 @@ that uses promises to return responses and errors (see json-rcp.js). array is organized from oldest temperature to most recent (left to right). Note that when the host starts each array is initialized to 0s. +### Fetch stored gcode info +- HTTP command:\ + `GET /server/gcode_store` + + Optionally, a `count` argument may be added to specify the number of lines fetch. + If omitted, the entire gcode store will be sent (up to 1000 lines). + + `GET /server/gcode_store?count=100` + +- Websocket command: + `{jsonrpc: "2.0", method: "server.gcode_store", id: }` + + OR + `{jsonrpc: "2.0", method: "server.gcode_store", + params: {count: } id: }` + +- Returns:\ + An object which includes a string containing up to 1000 lines of + stored gcode responses. Each line will be separated by a newline + character: +```json + { + gcode_store: + } +``` + ## Gcode Controls ### Run a gcode: