API for BambuLab 3D Printers over MQTT
Project description
Bambulabs API
This package provides a Python API for interacting with BambuLab 3D Printers. The API enables you to control and monitor your printer programmatically, making it an essential tool for developers, makers, and automation enthusiasts. The project is open-source and available on PyPI.
Status
Documentation
Comprehensive documentation for this package, including API reference and usage guides, can be found here.
Installation
To install the package, use pip
:
pip install bambulabs_api
Make sure you have Python 3.6 or higher installed.
Features
- Connect and control BambuLab 3D printers programmatically.
- Monitor printer status in real-time.
- Execute commands and manage print jobs directly through Python code.
- Easy setup and integration with Python environments.
Usage Example
Below is a basic example demonstrating how to connect to a BambuLab 3D printer and retrieve its status using the API:
import time
import bambulabs_api as bl
IP = '192.168.1.200'
SERIAL = 'AC12309BH109'
ACCESS_CODE = '12347890'
if __name__ == '__main__':
print('Starting bambulabs_api example')
print('Connecting to BambuLab 3D printer')
print(f'IP: {IP}')
print(f'Serial: {SERIAL}')
print(f'Access Code: {ACCESS_CODE}')
# Create a new instance of the API
printer = bl.Printer(IP, ACCESS_CODE, SERIAL)
# Connect to the BambuLab 3D printer
printer.connect()
time.sleep(2)
# Get the printer status
status = printer.get_state()
print(f'Printer status: {status}')
# Turn the light off
printer.turn_light_off()
time.sleep(2)
# Turn the light on
printer.turn_light_on()
# Disconnect from the Bambulabs 3D printer
printer.disconnect()
Development
If you want to contribute to the development of this API or run it in a development environment, follow these steps:
Prerequisites
- Conda: Make sure you have Conda installed on your system.
- Git: Ensure Git is installed for cloning the repository.
Setup
-
Clone the repository:
git clone https://github.com/mchrisgm/bambulabs_api.git
-
Change directory:
cd bambulabs_api
-
Create the Conda environment using the provided
environment.yml
file:conda env create -f environment.yml
-
Activate the environment:
conda activate blapi
-
Install the package in development mode:
pip install -e .
Running Tests
To ensure everything is working correctly, you can run the tests using pytest
:
pytest
Contributing
Contributions are welcome! If you'd like to contribute to this project, please:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
Please make sure your code follows PEP 8 guidelines and that you run tests before submitting a PR.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Support
If you encounter any issues or have questions, feel free to open an issue on the GitHub repository.
Acknowledgements
This package is an open-source project developed and maintained by the community. Special thanks to all contributors who have helped improve and enhance this API.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bambulabs_api-2.4.3.tar.gz
.
File metadata
- Download URL: bambulabs_api-2.4.3.tar.gz
- Upload date:
- Size: 3.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd8efa837e1065c85e44c65f40dfc8e6919f9ef50b60aba3275792bf53f87517 |
|
MD5 | 0fa558bff718b8f7952e4753764c6420 |
|
BLAKE2b-256 | 6fe5f862ee51fbfabf330b0f12bebac866e3a0653ac3156a7a19531b47dc2532 |
File details
Details for the file bambulabs_api-2.4.3-py3-none-any.whl
.
File metadata
- Download URL: bambulabs_api-2.4.3-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c71fe0772be77a6285f0b5012e871b57f26fdb387a0d0e214a96b7c251a7cae2 |
|
MD5 | a716f1a10c4bf58d886412eace331501 |
|
BLAKE2b-256 | 80d1319f98d4a910968a3285f28f83c337c4de7987096b526bf8eef14d8a195d |