diff --git a/docs/api_changes.md b/docs/api_changes.md index a02bcf3..d761ce4 100644 --- a/docs/api_changes.md +++ b/docs/api_changes.md @@ -1,6 +1,14 @@ This document keeps a record of all changes to Moonraker's remote facing APIs. +### October 21st 2020 +- The `/server/gcode_store` endpoint no longer returns a string + in the result's `gcode_store` field. It now returns an + Array of objects, each object containing `message` and `time` + fields. The time refers to a timestamp in unix time (seconds), + and may be used to determine when the gcode store received the + accompanying `message`. + ### September 30th 2020 - Two new endpoints have been added: - `GET /server/info` (`server.info`) diff --git a/docs/web_api.md b/docs/web_api.md index f0eb7af..f481ab5 100644 --- a/docs/web_api.md +++ b/docs/web_api.md @@ -233,8 +233,9 @@ that uses promises to return responses and errors (see json-rcp.js). - 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). + Optionally, a `count` argument may be added to specify the number of + responses to fetch. If omitted, the entire gcode store will be sent + (up to 1000 responses). `GET /server/gcode_store?count=100` @@ -246,14 +247,42 @@ that uses promises to return responses and errors (see json-rcp.js). 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: + An object with the field `gcode_store` that contains an array + of objects. Each object will contain a `message` field and a + `time` field: ```json { - gcode_store: + gcode_store: [ + { + message: , + time: unix_time_stamp + }, ... + ] } ``` +Each `message` field contains a gcode response received at the time +indicated in the `time` field. Note that the time stamp refers to +unix time (in seconds). This can be used to create a JavaScript +`Date` object: +```javascript +for (let resp of result.gcode_store) { + let date = new Date(resp.time * 1000); + // Do something with date and resp.message ... +} +``` + +### Restart Server +- HTTP command:\ + `POST /server/restart` + +- Websocket command: + `{jsonrpc: "2.0", method: "server.restart", id: }` + +- Returns:\ + `"ok"` upon receipt of the restart request. After the request + is returns, the server will restart. Any existing connection + will be disconnected. A restart will result in the creation + of a new server instance where the configuration is reloaded. ## Gcode Controls