|
| 1 | +# List of supported HTTP requests |
| 2 | + |
| 3 | +RepRapFirmware provides an HTTP interface for dealing with client requests. |
| 4 | +These requests are tailored for Duet Web Control in the first place but they may be used by third-party applications, too. |
| 5 | + |
| 6 | +Every request except for `rr_connect` returns HTTP status code `401` if the client does not have a valid session. |
| 7 | +If no machine password is set, a user session is created whenever an arbitrary HTTP request is made. |
| 8 | +Besides, RepRapFirmware may run short on memory and may not be able to respond properly. In this case, HTTP status code `503` is returned. |
| 9 | + |
| 10 | +In the following requests datetime strings may be used. These datetime strings are very similar to ISO8601-encoded strings but they do not contain timezone details. |
| 11 | +An example for such a string is `2019-12-13T21:27:00`. Make sure to follow this format where applicable. |
| 12 | + |
| 13 | +## GET /rr_connect |
| 14 | + |
| 15 | +Attempt to create a new connection and log in using the (optional) password. |
| 16 | + |
| 17 | +Supported parameters: |
| 18 | + |
| 19 | +- `password` (optional): Machine password to log in with. If omitted, this defaults to `reprap` |
| 20 | +- `time` (optional): Current datetime that will be used to update RepRapFirmware's internal clock |
| 21 | + |
| 22 | +Returns |
| 23 | + |
| 24 | +``` |
| 25 | +{ |
| 26 | + "err": code |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +where `code` may be one of the following: |
| 31 | + |
| 32 | +- `0`: Password is valid and the client's IP address is added to the list of HTTP sessions |
| 33 | +- `1`: Password is invalid |
| 34 | +- `2`: No more user sessions available. This may occur when too many client devices are connected at the same time |
| 35 | + |
| 36 | +If the password is valid, extra fields are returned: |
| 37 | + |
| 38 | +``` |
| 39 | +{ |
| 40 | + "err": 0, |
| 41 | + "sessionTimeout": 8000, |
| 42 | + "boardType": "duetwifi102" |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +- `sessionTimeout` is the idle timeout in milliseconds before a client is removed again from the list of client sessions |
| 47 | +- `boardType` represents the board's type |
| 48 | + |
| 49 | +Officially supported board types are: |
| 50 | + |
| 51 | +| boardType | Board | Remarks | |
| 52 | +| --------- | ----- | ------- | |
| 53 | +| duet06 | Duet 0.6 | deprecated | |
| 54 | +| duet07 | Duet 0.7 | deprecated | |
| 55 | +| duet085 | Duet 0.8.5 | deprecated | |
| 56 | +| duetwifi10 | Duet WiFi v1.0 || |
| 57 | +| duetwifi102 | Duet WiFi v1.02 || |
| 58 | +| duetethernet10 | Duet Ethernet v1.0 || |
| 59 | +| duetethernet102 | Duet Ethernet v1.02 || |
| 60 | +| duetmaestro100 | Duet Maestro v1.0 || |
| 61 | +| duet3mb6hc | Duet 3 v0.6 || |
| 62 | + |
| 63 | +## GET /rr_disconnect |
| 64 | + |
| 65 | +Disconnect again from the RepRapFirmware controller. |
| 66 | + |
| 67 | +Returns |
| 68 | + |
| 69 | +``` |
| 70 | +{ |
| 71 | + "err": code |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +where `code` may be `0` if the session could be removed, else it is `1`. |
| 76 | + |
| 77 | +## GET /rr_status |
| 78 | + |
| 79 | +Retrieve a status response from RepRapFirmware in JSON format. |
| 80 | + |
| 81 | +Supported parameters: |
| 82 | + |
| 83 | +- `type`: Type of the status response |
| 84 | + |
| 85 | +The value of `type` can be one of: |
| 86 | + |
| 87 | +- 1: Standard status response |
| 88 | +- 2: Advanced status response. This also contains fields from the standard status response |
| 89 | +- 3: Print status response. This contains fields from the standard status response as well as information about the current (print) job |
| 90 | + |
| 91 | +See [JSON responses](JSON%20Responses.md) for further information. |
| 92 | + |
| 93 | +## Get /rr_config |
| 94 | + |
| 95 | +Retrieve the configuration response. This request provides a JSON object with values that are expected to change rarely. |
| 96 | + |
| 97 | +See [JSON responses](JSON%20Responses.md) for further information. |
| 98 | + |
| 99 | +## GET /rr__gcode |
| 100 | + |
| 101 | +Execute arbitrary G/M/T-code(s). |
| 102 | + |
| 103 | +Supported parameters: |
| 104 | + |
| 105 | +- `gcode`: G/M/T-code to execute. This parameter must be present although it can be empty |
| 106 | + |
| 107 | +Returns |
| 108 | + |
| 109 | +``` |
| 110 | +{ |
| 111 | + "buff": bufferSpace |
| 112 | +} |
| 113 | +``` |
| 114 | + |
| 115 | +where `bufferSpace` indicates how much buffer space for new G/M/T-codes is still available. |
| 116 | + |
| 117 | +If a file is supposed to be streamed over the HTTP interface, call this repeatedly and transfer only as many bytes as allowed. |
| 118 | + |
| 119 | +## GET /rr_reply |
| 120 | + |
| 121 | +Retrieve the last G-code reply. The G-code reply is buffered per connected HTTP client and it is discarded when every HTTP client has fetched it or |
| 122 | +when the firmware is short on memory and the client has not requested it within reasonable time (1 second). |
| 123 | + |
| 124 | +The G-code reply is returned as `text/plain`. |
| 125 | + |
| 126 | +## GET /rr_upload |
| 127 | + |
| 128 | +Get the last file upload result. |
| 129 | + |
| 130 | +Returns |
| 131 | + |
| 132 | +``` |
| 133 | +{ |
| 134 | + "err": code |
| 135 | +} |
| 136 | +``` |
| 137 | + |
| 138 | +where `code` can be either `0` if the last upload successfully finished or `1` if an error occurred. |
| 139 | + |
| 140 | +## POST /rr_upload |
| 141 | + |
| 142 | +Upload a file. |
| 143 | + |
| 144 | +Supported URL parameters: |
| 145 | + |
| 146 | +- `name`: Path to the file to upload |
| 147 | +- `time` (optional): ISO8601-like represenation of the time the file was last modified |
| 148 | +- `crc32` (optional): CRC32 checksum of the file content as hex string *without* leading `0x`. Usage of this parameter is encouraged |
| 149 | + |
| 150 | +The raw HTTP body contains the file content. Binary file uploads are supported as well. |
| 151 | +Make sure to set `Content-Length` to the length of the HTTP body if your HTTP client does not already do that. |
| 152 | + |
| 153 | +Returns |
| 154 | + |
| 155 | +``` |
| 156 | +{ |
| 157 | + "err": code |
| 158 | +} |
| 159 | +``` |
| 160 | + |
| 161 | +where `code` can be either `0` if the last upload successfully finished or `1` if an error occurred (e.g. CRC mismatch). |
| 162 | + |
| 163 | +## GET /rr_download |
| 164 | + |
| 165 | +Download a file. |
| 166 | + |
| 167 | +Supported parameters: |
| 168 | + |
| 169 | +- `name`: Filename to download |
| 170 | + |
| 171 | +If the file could not be found, HTTP status code 404 is returned, else the file content is sent to the client. |
| 172 | + |
| 173 | +## GET /rr_delete |
| 174 | + |
| 175 | +Delete a file or directory. |
| 176 | + |
| 177 | +Supported parameters: |
| 178 | + |
| 179 | +- `name`: Filename to delete |
| 180 | + |
| 181 | +Returns |
| 182 | + |
| 183 | +``` |
| 184 | +{ |
| 185 | + "err": {code} |
| 186 | +} |
| 187 | +``` |
| 188 | + |
| 189 | +where code is either `0` on success or `1` on error. |
| 190 | + |
| 191 | +## GET /rr_filelist |
| 192 | + |
| 193 | +Retrieve a (partial) file list. |
| 194 | + |
| 195 | +Supported parameters: |
| 196 | + |
| 197 | +- `dir`: Directory to query |
| 198 | +- `first` (optional): First item index to return. Defaults to `0` |
| 199 | + |
| 200 | +Returns |
| 201 | +``` |
| 202 | +{ |
| 203 | + "dir": dir, |
| 204 | + "first": first, |
| 205 | + "files": [ |
| 206 | + { |
| 207 | + "type": itemType, |
| 208 | + "name": itemName, |
| 209 | + "size": itemSize, |
| 210 | + "date": itemDate |
| 211 | + }, |
| 212 | + ... |
| 213 | + ], |
| 214 | + "next": next, |
| 215 | + "err": code |
| 216 | +} |
| 217 | +``` |
| 218 | + |
| 219 | +where `dir` and `first` equal the query parameters. `err` can be one of: |
| 220 | + |
| 221 | +- `0`: List query successful |
| 222 | +- `1`: Drive is not mounted |
| 223 | +- `2`: Directory does not exist |
| 224 | + |
| 225 | +The `next` field may be omitted if the query was not successful and it is `0` if the query has finished. If there are more items to query, this value can be used for the `first` parameter of a successive `rr_filelist` request. |
| 226 | + |
| 227 | +Retrieved files are returned as part of the `files` array. Note that `date` may not be present if it is invalid. Every item has the following properties: |
| 228 | + |
| 229 | +- `itemType`: Type of the file item. This is `d` for directories and `f` for files |
| 230 | +- `itemName`: Name of the file or directory |
| 231 | +- `itemSize`: Size of the file. This is always `0` for directories |
| 232 | +- `itemDate`: Datetime of the last file modification |
| 233 | + |
| 234 | +## GET /rr_files |
| 235 | + |
| 236 | +Retrieve a list of files without any attributes. |
| 237 | + |
| 238 | +Supported parameters: |
| 239 | + |
| 240 | +- `dir`: Directory to query |
| 241 | +- `first` (optional): First item index to return. Defaults to `0` |
| 242 | +- `flagDirs` (optional): Set this to `1` to prefix directory items with `*`. Defaults to `0` |
| 243 | + |
| 244 | +Returns |
| 245 | + |
| 246 | +``` |
| 247 | +{ |
| 248 | + "dir": dir, |
| 249 | + "first": first, |
| 250 | + "files": [ |
| 251 | + "file1", |
| 252 | + "file2", |
| 253 | + ... |
| 254 | + ], |
| 255 | + "next": next, |
| 256 | + "err": err |
| 257 | +} |
| 258 | +``` |
| 259 | + |
| 260 | +where `dir` and `first` equal the query parameters. `err` can be one of: |
| 261 | + |
| 262 | +- `0`: List query successful |
| 263 | +- `1`: Drive is not mounted |
| 264 | +- `2`: Directory does not exist |
| 265 | + |
| 266 | +The `next` field may be omitted if the query was not successful and it is `0` if the query has finished. If there are more items to query, this value can be used for the `first` parameter of a successive `rr_files` request. |
| 267 | + |
| 268 | +## GET /rr_move |
| 269 | + |
| 270 | +Move a file or directory. |
| 271 | + |
| 272 | +Supported parameters: |
| 273 | + |
| 274 | +- `old`: Current path to the file or directory |
| 275 | +- `new`: New path of the file or directory |
| 276 | +- `deleteexisting` (optional): Set this to `yes` to delete the new file if it already exists. Defaults to `no` |
| 277 | + |
| 278 | +Returns |
| 279 | + |
| 280 | +``` |
| 281 | +{ |
| 282 | + "err": code |
| 283 | +} |
| 284 | +``` |
| 285 | + |
| 286 | +where code is either `0` on success or `1` on error. |
| 287 | + |
| 288 | +## GET /rr_mkdir |
| 289 | + |
| 290 | +Create a new directory. |
| 291 | + |
| 292 | +Supported parameters: |
| 293 | + |
| 294 | +- `dir`: Path to the new directory |
| 295 | + |
| 296 | +Returns |
| 297 | + |
| 298 | +``` |
| 299 | +{ |
| 300 | + "err": code |
| 301 | +| |
| 302 | +``` |
| 303 | + |
| 304 | +where code is either `0` on success or `1` on error. |
| 305 | + |
| 306 | +## GET /rr_fileinfo |
| 307 | + |
| 308 | +Parse a G-code job file and return retrieved information. If no file is specified, information about the file being printed is returned. |
| 309 | + |
| 310 | +Supported parameters: |
| 311 | + |
| 312 | +- `name` (optional): Path to the file to parse |
| 313 | + |
| 314 | +Returns |
| 315 | + |
| 316 | +``` |
| 317 | +{ |
| 318 | + "err": code, |
| 319 | + "size": size, |
| 320 | + "lastModified": lastModified, |
| 321 | + "height": height, |
| 322 | + "firstLayerHeight": firstLayerHeight, |
| 323 | + "layerHeight": layerHeight, |
| 324 | + "printTime": printTime, |
| 325 | + "simulatedTime": simulatedTime, |
| 326 | + "filament": filament, |
| 327 | + "printDuration": printDuration, |
| 328 | + "fileName": fileName, |
| 329 | + "generatedBy": generatedBy |
| 330 | +} |
| 331 | +``` |
| 332 | + |
| 333 | +where `code` is either `0` on success or `1` on error. If the file could not be parsed, all other fields are omitted. |
| 334 | + |
| 335 | +Other fields are: |
| 336 | + |
| 337 | +| Field | Unit | Description | Default value if invalid | Present if `name` is omitted | |
| 338 | +| ----- | ---- | ----------- | ------------------------ | --------------------------- | |
| 339 | +| size | bytes | Size of the file in bytes | not applicable | yes | |
| 340 | +| lastModified | datetime | Datetime of the last file modification | omitted | maybe | |
| 341 | +| height | mm | Final print height of the object | 0.00 | yes | |
| 342 | +| firstLayerHeight | mm | Height of the first layer | 0.00 | yes | |
| 343 | +| layerHeight | mm | Layer height | 0.00 | yes | |
| 344 | +| printTime | seconds | Estimated print time | omitted | maybe | |
| 345 | +| simulatedTime | seconds | Estimated print time according to the last simulation | omitted | maybe | |
| 346 | +| filament | array of mm | Total filament consumption per extruder | empty array | yes | |
| 347 | +| printDuration | seconds | Total print time so far | not applicable | no | |
| 348 | +| fileName | file path | Absolute path to the file being printed | not applicable | no | |
| 349 | +| generatedBy | text | Slicer or toolchain which generated this file | empty string | yes | |
0 commit comments