Skip to content

Repository files navigation

DuetWebAPI

Python interface to Duet RepRap V3 firmware via Http REST API.

  • Works over IP network.
  • Does not support passwords on the printer.
  • Supported boards:
    • Duet 3 + SBC
    • Duet 3 standalone
    • Duet 2 standalone

Install

pip install duetwebapi

Alternatively:

pip install -e "git+https://github.com/AndyEveritt/DuetWebAPI.git@master#egg=duetwebapi"

Usage

  • See 'examples.py' for examples.
fromduetwebapiimportDuetWebAPIprinter=DuetWebAPI(f'http://{printer_hostname}')

REST API

The REST API allows for the following operations:

MethodDescription
connect(password: str = '') -> DictStart a connection with Duet. DWC api only
disconnect() -> DictEnd a connection with Duet. DWC api only
get_model(key: str = None, depth: int = 99, verbose: bool = True, null: bool = True, frequent: bool = False, obsolete: bool = False) -> DictGet Duet object model. RRF3 only. Flags only supported in DWC api.
send_code(code: str) -> DictSend G/M/T-code to Duet
get_file(filename: str, directory: str = 'gcodes', binary: bool = False) -> strDownload file from Duet
upload_file(file: str | bytes | StringIO | TextIOWrapper | BytesIO, filename: str, directory: str = 'gcodes') -> DictUpload file to Duet
get_fileinfo(filename: str = None, directory: str = 'gcodes') -> DictGet file info
delete_file(filename: str, directory: str = 'gcodes') -> DictDelete file on Duet
move_file(from_path: str, to_path: str, force: bool = False) -> DictMove file on Duet, can be used to rename files
get_directory(directory: str) -> List[Dict]Get a list of all the files & directories in a directory
create_directory(directory: str) -> DictCreate a new directory

Wrapper

An additional wrapper is provided to make repetative tasks easier

MethodDescription
emergency_stop() -> NoneSend M112 > M999
start_print(filename: str) -> Dictstart a print on duet
pause_print() -> Dictpause current print
stop_print(leave_heaters: bool) -> Dictstop current print, will pause first if not paused
get_coords() -> Dictreturn the current position of all the movement axes
get_layer() -> intreturn the current layer number of the print
get_num_extruders() -> intreturn the number of extruders currently configured
get_num_tools() -> intreturn the number of tools currently configured
get_status() -> strreturn the current Duet status
get_temperature() -> List[Dict]return a list of all the analog sensors and their value
get_current_tool() -> intreturn the current tool number
get_messagebox() -> Dictreturn the details of a message displayed via M291 if one exists
acknowledge_message(response: int) -> Dictsend an acknowledgement to a message if one exists. Response options are 0 (continue), and 1 (cancel)

About

Python wrapper for the Reprapfirmware 3 Duet REST API on Duet 3 & 2

Topics

Resources

Stars

17 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages