go-octoprint
go-octoprint copied to clipboard
Go library for accessing the OctoPrint's REST API
go-octoprint

Go library for accessing the OctoPrint's REST API.
Installation
The recommended way to install go-octoprint
go get github.com/mcuadros/go-octoprint
Example
Retrieving the current connection state:
client, _ := NewClient("<octoprint-url>", "<api-key>")
r := octoprint.ConnectionRequest{}
s, err := r.Do(client)
if err != nil {
log.Error("error requesting connection state: %s", err)
}
fmt.Printf("Connection State: %q\n", s.Current.State)
Retrieving current temperature for bed and extruders:
r := octoprint.StateRequest{}
s, err := r.Do(c)
if err != nil {
log.Error("error requesting state: %s", err)
}
fmt.Println("Current Temperatures:")
for tool, state := range s.Temperature.Current {
fmt.Printf("- %s: %.1f°C / %.1f°C\n", tool, state.Actual, state.Target)
}
Implemented Methods
Version Information
- [x] GET
/api/version
Apps
- [ ] GET
/apps/auth - [ ] POST
/apps/auth
Connection Operations
- [x] GET
/api/connection - [x] POST
/api/connection
File Operations
- [x] GET `/api/files
- [x] GET
/api/files/<location> - [x] POST
/api/files/<location> - [x] GET
/api/files/<location>/<filename> - [x] POST
/api/files/<location>/<path>(Only select command) - [x] DELETE
/api/files/<location>/<path>
Job Operations
- [x] POST
/api/job - [x] GET
/api/job
Languages
- [ ] GET
/api/languages - [ ] POST
/api/languages - [ ] DELETE
/api/languages/<locale>/<pack>
Log file management
- [ ] GET
/api/logs - [ ] DELETE
/api/logs/<filename>
Printer Operations
- [x] GET
/api/printer - [x] POST
/api/printer/printhead - [x] POST
/api/printer/tool - [x] GET
/api/printer/tool - [x] POST
/api/printer/bed - [x] GET
/api/printer/bed - [x] POST
/api/printer/sd - [x] GET
/api/printer/sd - [x] POST
/api/printer/command - [x] GET
/api/printer/command/custom(un-documented at REST API)
Printer profile operations
- [ ] GET
/api/printerprofiles - [ ] POST
/api/printerprofiles - [ ] PATCH
/api/printerprofiles/<profile> - [ ] DELETE
/api/printerprofiles/<profile>
Settings
- [x] GET
/api/settings - [ ] POST
/api/settings - [ ] POST
/api/settings/apikey
Slicing
- [ ] GET
/api/slicing - [ ] GET
/api/slicing/<slicer>/profiles - [ ] GET
/api/slicing/<slicer>/profiles/<key> - [ ] PUT
/api/slicing/<slicer>/profiles/<key> - [ ] DELETE
/api/slicing/<slicer>/profiles/<key>
System
- [x] GET
/api/system/commands - [ ] GET
/api/system/commands/<source> - [x] POST
/api/system/commands/<source>/<action>
Timelapse
- [ ] GET
/api/timelapse - [ ] DELETE
/api/timelapse/<filename> - [ ] POST
/api/timelapse/unrendered/<name> - [ ] DELETE
/api/timelapse/unrendered/<name> - [ ] POST
/api/timelapse
User
- [ ] GET
/api/users - [ ] GET
/api/users/<username> - [ ] POST
/api/users - [ ] PUT
/api/users/<username> - [ ] DELETE
/api/users/<username> - [ ] PUT
/api/users/<username>/password - [ ] GET
/api/users/<username>/settings - [ ] PATCH
/api/users/<username>/settings - [ ] POST
/api/users/<username>/apikey - [ ] DELETE
/api/users/<username>/apikey
Util
- [ ] POST
/api/util/test
Wizard
- [ ] GET
/setup/wizard - [ ] POST
/setup/wizard
License
MIT, see LICENSE