BambuLabs API

Description

API for accessing information for a printer, including the status of the printer and the status of the print job.

Printer

Client Class for connecting to the Bambulabs 3D printer

bambulabs_api.Printer.calibrate_printer(self, bed_level: bool = True, motor_noise_calibration: bool = True, vibration_compensation: bool = True) bool

Calibrate the printer.

Parameters:
  • bed_level (bool, optional) – Whether to calibrate the bed level, by default True.

  • motor_noise_calibration (bool, optional) – Whether to calibrate the motor noise, by default True.

  • vibration_compensation (bool, optional) – Whether to calibrate the vibration compensation, by default True.

Returns:

True if the printer is calibrated successfully.

Return type:

bool

bambulabs_api.Printer.connect(self)

Connect to the printer

bambulabs_api.Printer.delete_file(self, file_path: str) str

Delete a file from the printer.

Parameters:

file_path (str) – The path of the file to be deleted.

Returns:

The path of the deleted file.

Return type:

str

bambulabs_api.Printer.disconnect(self)

Disconnect from the printer

bambulabs_api.Printer.gcode(self, gcode: str | list[str]) bool

Send a gcode command to the printer.

Parameters:

gcode (str | list[str]) – The gcode command or list of gcode commands to be sent.

Returns:

True if the gcode command is sent successfully.

Return type:

bool

Raises:

ValueError – If the gcode command is invalid.

bambulabs_api.Printer.get_bed_temperature(self) float | None

Get the bed temperature of the printer. NOT IMPLEMENTED YET

Returns:

  • float – The bed temperature of the printer.

  • None if the printer is not printing.

bambulabs_api.Printer.get_camera_frame(self) str

Get the camera frame of the printer.

Returns:

Base64 encoded image of the camera frame.

Return type:

str

bambulabs_api.Printer.get_current_state(self) PrintStatus

Get the current state of the printer.

Returns:

The current state of the printer.

Return type:

PrintStatus

bambulabs_api.Printer.get_file_name(self) str

Get the name of the file being printed.

Returns:

The name of the file being printed.

Return type:

str

bambulabs_api.Printer.get_light_state(self) str

Get the state of the printer light.

Returns:

The state of the printer light.

Return type:

str

bambulabs_api.Printer.get_nozzle_temperature(self) float | None

Get the nozzle temperature of the printer. NOT IMPLEMENTED YET

Returns:

  • float – The nozzle temperature of the printer.

  • None if the printer is not printing.

bambulabs_api.Printer.get_percentage(self) int | str | None

Get the percentage of the print job completed.

Returns:

  • int – Percentage of the print job completed.

  • str – “Unknown” if the percentage is unknown.

  • None if the printer is not printing.

bambulabs_api.Printer.get_print_speed(self) int

Get the print speed of the printer.

Returns:

The print speed of the printer.

Return type:

int

bambulabs_api.Printer.get_skipped_objects(self) list[int]

Get the current state of the printer.

Returns:

The current state of the printer.

Return type:

PrintStatus

bambulabs_api.Printer.get_state(self) str

Get the state of the printer.

Returns:

The state of the printer.

Return type:

str

bambulabs_api.Printer.get_time(self) int | str | None

Get the remaining time of the print job in seconds.

Returns:

  • int – Remaining time of the print job in seconds.

  • str – “Unknown” if the remaining time is unknown.

  • None if the printer is not printing.

bambulabs_api.Printer.home_printer(self) bool

Home the printer.

Returns:

True if the printer is homed successfully.

Return type:

bool

bambulabs_api.Printer.load_filament_spool(self) bool

Load the filament spool to the printer.

Returns:

True if the filament spool is loaded successfully.

Return type:

bool

bambulabs_api.Printer.move_z_axis(self, height: int) bool

Move the Z-axis of the printer.

Parameters:

height (float) – The height for the bed.

Returns:

True if the Z-axis is moved successfully.

Return type:

bool

bambulabs_api.Printer.pause_print(self) bool

Pause the printer from printing.

Returns:

True if the printer is paused successfully.

Return type:

bool

bambulabs_api.Printer.resume_print(self) bool

Resume the printer from printing.

Returns:

True if the printer is resumed successfully.

Return type:

bool

bambulabs_api.Printer.retry_filament_action(self) bool

Retry the filament action.

Returns:

True if the filament action is retried successfully.

Return type:

bool

bambulabs_api.Printer.set_auto_step_recovery(self, auto_step_recovery: bool = True) bool

Set whether or not to set auto step recovery

Parameters:

auto_step_recovery (bool) – flag to set auto step recovery. Default True.

Returns:

success of the auto step recovery command command

Return type:

bool

bambulabs_api.Printer.set_aux_fan_speed(self, speed: int | float) bool

Set the fan speed of the aux part fan

Parameters:

speed (int | float) – The speed to set the part fan

Returns:

success of setting the fan speed

Return type:

bool

bambulabs_api.Printer.set_bed_temperature(self, temperature: int) bool

Set the bed temperature of the printer.

Parameters:

temperature (int) – The temperature to be set.

Returns:

True if the temperature is set successfully.

Return type:

bool

bambulabs_api.Printer.set_chamber_fan_speed(self, speed: int | float) bool

Set the fan speed of the chamber fan

Parameters:

speed (int | float) – The speed to set the part fan

Returns:

success of setting the fan speed

Return type:

bool

bambulabs_api.Printer.set_filament_printer(self, color: str, filament: str | AMSFilamentSettings) bool

Set the filament of the printer.

Parameters:
  • color (str) – The color of the filament.

  • filament (str | AMSFilamentSettings) – The filament to be set.

Returns:

True if the filament is set successfully.

Return type:

bool

bambulabs_api.Printer.set_nozzle_temperature(self, temperature: int) bool

Set the nozzle temperature of the printer.

Parameters:

temperature (int) – The temperature to be set.

Returns:

True if the temperature is set successfully.

Return type:

bool

bambulabs_api.Printer.set_part_fan_speed(self, speed: int | float) bool

Set the fan speed of the part fan

Parameters:

speed (int | float) – The speed to set the part fan

Returns:

success of setting the fan speed

Return type:

bool

bambulabs_api.Printer.set_print_speed(self, speed_lvl: int) bool

Set the print speed of the printer.

Parameters:

speed_lvl (int) – The speed level to be set. 0: Slowest 1: Slow 2: Fast 3: Fastest

Returns:

True if the speed level is set successfully.

Return type:

bool

bambulabs_api.Printer.skip_objects(self, obj_list: list[int]) bool

Skip Objects during printing.

Parameters:

obj_list (list[int]) – object list to skip objects.

Returns:

if publish command is successful

Return type:

bool

bambulabs_api.Printer.start_print(self, filename: str, plate_number: int, use_ams: bool = True, ams_mapping: list[int] = [0], skip_objects: list[int] | None = None) bool

Start printing a file.

Parameters:
  • filename (str) – The name of the file to be printed.

  • plate_number (int) – The plate number of the file to be printed.

  • use_ams (bool, optional) – Whether to use the AMS system, by default True.

  • ams_mapping (list[int], optional) – The mapping of the filament trays to the plate numbers, by default [0].

  • None (skip_objects (list[int] |) – skip. Defaults to None.

  • optional) (List of gcode objects to) – skip. Defaults to None.

Returns:

True if the file is printed successfully.

Return type:

bool

bambulabs_api.Printer.stop_print(self) bool

Stop the printer from printing.

Returns:

True if the printer is stopped successfully.

Return type:

bool

bambulabs_api.Printer.turn_light_off(self) bool

Turn off the printer light.

Returns:

True if the light is turned off successfully.

Return type:

bool

bambulabs_api.Printer.turn_light_on(self) bool

Turn on the printer light.

Returns:

True if the light is turned on successfully.

Return type:

bool

bambulabs_api.Printer.unload_filament_spool(self) bool

Unload the filament spool from the printer.

Returns:

True if the filament spool is unloaded successfully.

Return type:

bool

bambulabs_api.Printer.upload_file(self, file: BinaryIO, filename: str = 'ftp_upload.gcode') str

Upload a file to the printer.

Parameters:
  • file (BinaryIO) – The file to be uploaded.

  • filename (str, optional) – The name of the file, by default “ftp_upload.gcode”.

Returns:

The path of the uploaded file.

Return type:

str

Filament

Enum class for the filament settings

The filament settings are a set of values that indicate the settings of the filament.

bambulabs_api.Filament.POLYLITE_PLA
Type:

The Polylite PLA filament settings.

bambulabs_api.Filament.POLYTERRA_PLA
Type:

The Polyterra PLA filament settings.

bambulabs_api.Filament.BAMBU_ABS
Type:

The Bambu ABS filament settings.

bambulabs_api.Filament.BAMBU_PA_CF
Type:

The Bambu PA-CF filament settings.

bambulabs_api.Filament.BAMBU_PC
Type:

The Bambu PC filament settings.

bambulabs_api.Filament.BAMBU_PLA_Basic
Type:

The Bambu PLA Basic filament settings.

bambulabs_api.Filament.BAMBU_PLA_Matte
Type:

The Bambu PLA Matte filament settings.

bambulabs_api.Filament.SUPPORT_G
Type:

The Support G filament settings.

bambulabs_api.Filament.SUPPORT_W
Type:

The Support W filament settings.

bambulabs_api.Filament.BAMBU_TPU_95A
Type:

The Bambu TPU 95A filament settings.

bambulabs_api.Filament.ABS
Type:

The ABS filament settings.

bambulabs_api.Filament.ASA
Type:

The ASA filament settings.

bambulabs_api.Filament.PA
Type:

The PA filament settings.

bambulabs_api.Filament.PA_CF
Type:

The PA-CF filament settings.

bambulabs_api.Filament.PC
Type:

The PC filament settings.

bambulabs_api.Filament.PETG
Type:

The PETG filament settings.

bambulabs_api.Filament.PLA
Type:

The PLA filament settings.

bambulabs_api.Filament.PLA_CF
Type:

The PLA-CF filament settings.

bambulabs_api.Filament.PVA
Type:

The PVA filament settings.

bambulabs_api.Filament.TPU
Type:

The TPU filament settings.

AMSFilamentSettings

Dataclass for the filament settings

The filament settings are a set of values that indicate the settings of the filament.

bambulabs_api.AMSFilamentSettings.tray_info_idx
Type:

The tray info index.

bambulabs_api.AMSFilamentSettings.nozzle_temp_min
Type:

The minimum nozzle temperature.

bambulabs_api.AMSFilamentSettings.nozzle_temp_max
Type:

The maximum nozzle temperature.

bambulabs_api.AMSFilamentSettings.tray_type
Type:

The tray type.

PrintStatus

Enum class for the printer status

The printer status is a value that indicates the current state of the printer.

bambulabs_api.PrintStatus.PRINTING
Type:

The printer is currently printing.

bambulabs_api.PrintStatus.AUTO_BED_LEVELING
Type:

The printer is performing an automatic bed leveling.

bambulabs_api.PrintStatus.HEATBED_PREHEATING
Type:

The printer is preheating the heatbed.

bambulabs_api.PrintStatus.SWEEPING_XY_MECH_MODE
Type:

The printer is performing a sweeping XY mechanical mode.

bambulabs_api.PrintStatus.CHANGING_FILAMENT
Type:

The printer is changing the filament.

bambulabs_api.PrintStatus.M400_PAUSE
Type:

The printer is paused.

bambulabs_api.PrintStatus.PAUSED_FILAMENT_RUNOUT
Type:

The printer is paused due to filament runout.

bambulabs_api.PrintStatus.HEATING_HOTEND
Type:

The printer is heating the hotend.

bambulabs_api.PrintStatus.CALIBRATING_EXTRUSION
Type:

The printer is calibrating the extrusion.

bambulabs_api.PrintStatus.SCANNING_BED_SURFACE
Type:

The printer is scanning the bed surface.

bambulabs_api.PrintStatus.INSPECTING_FIRST_LAYER
Type:

The printer is inspecting the first layer.

bambulabs_api.PrintStatus.IDENTIFYING_BUILD_PLATE_TYPE
Type:

The printer is identifying the build plate type.

bambulabs_api.PrintStatus.CALIBRATING_MICRO_LIDAR
Type:

The printer is calibrating the micro LiDAR.

bambulabs_api.PrintStatus.HOMING_TOOLHEAD
Type:

The printer is homing the toolhead.

bambulabs_api.PrintStatus.CLEANING_NOZZLE_TIP
Type:

The printer is cleaning the nozzle tip.

bambulabs_api.PrintStatus.CHECKING_EXTRUDER_TEMPERATURE
Type:

The printer is checking the extruder temperature.

bambulabs_api.PrintStatus.PAUSED_USER
Type:

The printer is paused by the user.

bambulabs_api.PrintStatus.PAUSED_FRONT_COVER_FALLING
Type:

The printer is paused due to the front cover falling.

bambulabs_api.PrintStatus.CALIBRATING_LIDAR
Type:

The printer is calibrating the LiDAR.

bambulabs_api.PrintStatus.CALIBRATING_EXTRUSION_FLOW
Type:

The printer is calibrating the extrusion flow.

bambulabs_api.PrintStatus.PAUSED_NOZZLE_TEMPERATURE_MALFUNCTION
Type:

The printer is paused due to a nozzle temperature malfunction.

bambulabs_api.PrintStatus.PAUSED_HEAT_BED_TEMPERATURE_MALFUNCTION
Type:

The printer is paused due to a heat bed temperature malfunction.

bambulabs_api.PrintStatus.FILAMENT_UNLOADING
Type:

The printer is unloading the filament.

bambulabs_api.PrintStatus.PAUSED_SKIPPED_STEP
Type:

The printer is paused due to a skipped step.

bambulabs_api.PrintStatus.FILAMENT_LOADING
Type:

The printer is loading the filament.

bambulabs_api.PrintStatus.CALIBRATING_MOTOR_NOISE
Type:

The printer is calibrating the motor noise.

bambulabs_api.PrintStatus.PAUSED_AMS_LOST
Type:

The printer is paused due to an AMS lost.

bambulabs_api.PrintStatus.PAUSED_LOW_FAN_SPEED_HEAT_BREAK
Type:

The printer is paused due to a low fan speed heat break.

bambulabs_api.PrintStatus.PAUSED_CHAMBER_TEMPERATURE_CONTROL_ERROR
Type:

The printer is paused due to a chamber temperature control error.

bambulabs_api.PrintStatus.COOLING_CHAMBER
Type:

The printer is cooling the chamber.

bambulabs_api.PrintStatus.PAUSED_USER_GCODE
Type:

The printer is paused by the user GCODE.

bambulabs_api.PrintStatus.MOTOR_NOISE_SHOWOFF
Type:

The printer is showing off the motor noise.

bambulabs_api.PrintStatus.PAUSED_NOZZLE_FILAMENT_COVERED_DETECTED
Type:

The printer is paused due to a nozzle filament covered detected.

bambulabs_api.PrintStatus.PAUSED_CUTTER_ERROR
Type:

The printer is paused due to a cutter error.

bambulabs_api.PrintStatus.PAUSED_FIRST_LAYER_ERROR
Type:

The printer is paused due to a first layer error.

bambulabs_api.PrintStatus.PAUSED_NOZZLE_CLOG
Type:

The printer is paused due to a nozzle clog.

bambulabs_api.PrintStatus.UNKNOWN
Type:

The printer status is unknown.

bambulabs_api.PrintStatus.IDLE
Type:

The printer is idle.

GcodeState

Enum class for the Gcode State

Gcode State that the printer can be in.

bambulabs_api.GcodeState.IDLE
Type:

The printer is idle.

bambulabs_api.GcodeState.PREPARING
Type:

The printer is preparing (File upload).

bambulabs_api.GcodeState.RUNNING
Type:

The printer is running.

bambulabs_api.GcodeState.PAUSED
Type:

The printer is paused.

bambulabs_api.GcodeState.FINISHED
Type:

The printer has finished.

bambulabs_api.GcodeState.UNKNOWN
Type:

The printer state is unknown.

bambulabs_api.GcodeState.FAILED
Type:

The printer has failed.