flashforge-python-api 1.1.0__py3-none-any.whl → 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,305 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: flashforge-python-api
3
- Version: 1.1.0
4
- Summary: A comprehensive Python library for controlling FlashForge 3D printers
5
- Project-URL: Homepage, https://github.com/GhostTypes/ff-5mp-api-py
6
- Project-URL: Documentation, https://github.com/GhostTypes/ff-5mp-api-py#readme
7
- Project-URL: Repository, https://github.com/GhostTypes/ff-5mp-api-py.git
8
- Project-URL: Issues, https://github.com/GhostTypes/ff-5mp-api-py/issues
9
- Author-email: GhostTypes <notghosttypes@gmail.com>
10
- License-Expression: MIT
11
- License-File: LICENSE
12
- Keywords: 3d-printer,api,async,control,flashforge,python
13
- Classifier: Development Status :: 5 - Production/Stable
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Topic :: Scientific/Engineering
20
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
- Classifier: Topic :: System :: Hardware :: Hardware Drivers
22
- Requires-Python: >=3.11
23
- Requires-Dist: aiohttp>=3.8.0
24
- Requires-Dist: netifaces>=0.11.0
25
- Requires-Dist: pydantic>=2.0.0
26
- Requires-Dist: requests>=2.31.0
27
- Provides-Extra: all
28
- Requires-Dist: black>=23.0.0; extra == 'all'
29
- Requires-Dist: mypy>=1.0.0; extra == 'all'
30
- Requires-Dist: pillow>=10.0.0; extra == 'all'
31
- Requires-Dist: pre-commit>=3.0.0; extra == 'all'
32
- Requires-Dist: pytest-asyncio>=0.21.0; extra == 'all'
33
- Requires-Dist: pytest-cov>=4.0.0; extra == 'all'
34
- Requires-Dist: pytest>=7.0.0; extra == 'all'
35
- Requires-Dist: ruff>=0.1.0; extra == 'all'
36
- Provides-Extra: dev
37
- Requires-Dist: black>=23.0.0; extra == 'dev'
38
- Requires-Dist: mypy>=1.0.0; extra == 'dev'
39
- Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
40
- Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
41
- Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
42
- Requires-Dist: pytest>=7.0.0; extra == 'dev'
43
- Requires-Dist: ruff>=0.1.0; extra == 'dev'
44
- Provides-Extra: imaging
45
- Requires-Dist: pillow>=10.0.0; extra == 'imaging'
46
- Description-Content-Type: text/markdown
47
-
48
- <div align="center">
49
-
50
- # FlashForge Python API
51
-
52
- **A comprehensive Python library for controlling FlashForge 3D printers**
53
-
54
- ![PyPI](https://img.shields.io/pypi/v/flashforge-python-api?style=flat&color=3776ab) ![Python](https://img.shields.io/badge/Python-3.11%2B-3776ab?style=flat) ![License](https://img.shields.io/badge/License-MIT-brightgreen?style=flat) ![Status](https://img.shields.io/badge/Status-Stable-brightgreen?style=flat)
55
-
56
- ![aiohttp](https://img.shields.io/badge/aiohttp-%E2%89%A53.8.0-blue?style=flat) ![pydantic](https://img.shields.io/badge/pydantic-%E2%89%A52.0.0-e92063?style=flat) ![netifaces](https://img.shields.io/badge/netifaces-%E2%89%A50.11.0-orange?style=flat) ![requests](https://img.shields.io/badge/requests-%E2%89%A52.31.0-blue?style=flat) ![pillow](https://img.shields.io/badge/pillow-%E2%89%A510.0.0-yellow?style=flat)
57
-
58
- **Dual-protocol support with modern async/await architecture for seamless printer control and monitoring**
59
-
60
- </div>
61
-
62
- ---
63
-
64
- <div align="center">
65
-
66
- ## Features
67
-
68
- | Capability | Details |
69
- | --- | --- |
70
- | **Dual Protocol Support** | Modern HTTP REST API for Adventurer 5M/5X series • Legacy TCP G-code protocol for all networked FlashForge printers |
71
- | **Printer Discovery** | Automatic UDP broadcast discovery • Returns printer name, serial number, and IP address |
72
- | **Full Control** | Movement and homing • Temperature control • Fan speed adjustment • LED lighting • Camera control • Air filtration system |
73
- | **Real-time Monitoring** | Printer status and machine state • Current and target temperatures • Print progress and layer tracking • Estimated time remaining |
74
- | **Job Management** | Start, pause, resume, and cancel print jobs • Progress monitoring |
75
- | **File Operations** | List, upload, and download files • Extract print thumbnails • File metadata retrieval |
76
- | **Async Architecture** | Native async/await implementation • Non-blocking network operations • Concurrent operations support |
77
- | **Type Safety** | Full type hints for IDE autocomplete • Pydantic models for data validation • mypy strict mode compatible |
78
- | **Model Detection** | Automatic capability detection • Runtime camera stream detection via `camera_stream_url` • Graceful degradation for older models |
79
-
80
- </div>
81
-
82
- ---
83
-
84
- <div align="center">
85
-
86
- ## Printer Testing & Coverage
87
-
88
- | Printer Model | Support Status | Testing Status | API Type |
89
- | --- | --- | --- | --- |
90
- | **AD5X** | Full | Tested | HTTP (New) + TCP |
91
- | **Adventurer 5M/Pro** | Full | Tested | HTTP (New) + TCP |
92
- | **Adventurer 3/4** | Partial | Partial | TCP (Legacy) |
93
-
94
- </div>
95
-
96
- ---
97
-
98
- <div align="center">
99
-
100
- ## Installation
101
-
102
- | Method | Command |
103
- | --- | --- |
104
- | **PyPI (Recommended)** | `pip install flashforge-python-api` |
105
- | **Development Install** | `pip install -e ".[dev]"` |
106
- | **With Imaging Support** | `pip install flashforge-python-api[imaging]` |
107
- | **All Optional Dependencies** | `pip install flashforge-python-api[all]` |
108
-
109
- </div>
110
-
111
- ---
112
-
113
- ## Quick Start
114
-
115
- <div align="center">
116
-
117
- **Important: LAN-Only Mode Required**
118
-
119
- Your printer must be in **LAN-only mode** to communicate with this library. See the [official FlashForge guide](https://wiki.flashforge.com/en/Orca-Flashforge-and-Flashmaker/orca-flashforge-quick-start-guide#connect-via-lan-only-mode) for setup instructions and to obtain your check code.
120
-
121
- </div>
122
-
123
- ### Printer Discovery
124
-
125
- Discover FlashForge printers on your local network automatically:
126
-
127
- ```python
128
- from flashforge import FlashForgePrinterDiscovery
129
- import asyncio
130
-
131
- async def discover():
132
- discovery = FlashForgePrinterDiscovery()
133
- printers = await discovery.discover_printers_async()
134
-
135
- for printer in printers:
136
- print(f"Found: {printer.name} at {printer.ip_address}")
137
- print(f"Serial: {printer.serial_number}")
138
-
139
- asyncio.run(discover())
140
- ```
141
-
142
- ### Basic Printer Control
143
-
144
- Connect to a printer and perform basic operations:
145
-
146
- ```python
147
- from flashforge import FlashForgeClient
148
- import asyncio
149
-
150
- async def control_printer():
151
- # Initialize client with printer credentials
152
- client = FlashForgeClient("192.168.1.100", "SERIAL_NUMBER", "CHECK_CODE")
153
-
154
- # Always initialize before operations
155
- if await client.initialize():
156
- print(f"Connected to {client.printer_name}")
157
- print(f"Firmware: {client.firmware_version}")
158
-
159
- # Set temperatures
160
- await client.temp_control.set_bed_temp(60)
161
- await client.temp_control.set_extruder_temp(220)
162
-
163
- # Home all axes
164
- await client.control.home_xyz()
165
-
166
- # Turn on LED lights (AD5M/5X only)
167
- if client.is_ad5x:
168
- await client.control.set_led_on()
169
-
170
- # Clean up
171
- await client.dispose()
172
-
173
- asyncio.run(control_printer())
174
- ```
175
-
176
- ### Real-time Status Monitoring
177
-
178
- Monitor printer status, temperatures, and print progress:
179
-
180
- ```python
181
- from flashforge import FlashForgeClient
182
- import asyncio
183
-
184
- async def monitor_printer():
185
- async with FlashForgeClient("192.168.1.100", "SERIAL", "CODE") as client:
186
- # Get comprehensive status via HTTP
187
- status = await client.get_printer_status()
188
- print(f"State: {status.machine_state}")
189
- print(f"Progress: {status.print_progress}%")
190
-
191
- # Get real-time temperatures via TCP
192
- temps = await client.tcp_client.get_temp_info()
193
- if temps:
194
- bed = temps.get_bed_temp()
195
- extruder = temps.get_extruder_temp()
196
- print(f"Bed: {bed.get_current()}°C / {bed.get_target()}°C")
197
- print(f"Extruder: {extruder.get_current()}°C / {extruder.get_target()}°C")
198
-
199
- # Check print progress via TCP
200
- layer_p, sd_p, current_layer = await client.tcp_client.get_print_progress()
201
- print(f"Layer Progress: {layer_p}% (Layer {current_layer})")
202
-
203
- asyncio.run(monitor_printer())
204
- ```
205
-
206
- ### Camera Stream Detection
207
-
208
- Use the printer-reported runtime camera stream URL as the OEM camera source of truth:
209
-
210
- ```python
211
- from flashforge import FlashForgeClient
212
- import asyncio
213
-
214
- async def check_camera():
215
- async with FlashForgeClient("192.168.1.100", "SERIAL", "CODE") as client:
216
- if not await client.initialize():
217
- return
218
-
219
- if client.camera_stream_url:
220
- print(f"OEM camera stream: {client.camera_stream_url}")
221
- else:
222
- print("Printer is not reporting an active OEM camera stream")
223
-
224
- # Camera power control remains Pro-only.
225
- if client.is_pro:
226
- await client.control.turn_camera_on()
227
-
228
- asyncio.run(check_camera())
229
- ```
230
-
231
- ### File Operations and Thumbnails
232
-
233
- List files and extract G-code thumbnails:
234
-
235
- ```python
236
- from flashforge import FlashForgeClient
237
- import asyncio
238
-
239
- async def file_operations():
240
- async with FlashForgeClient("192.168.1.100", "SERIAL", "CODE") as client:
241
- # List all files on printer
242
- files = await client.files.get_file_list()
243
- print(f"Found {len(files)} files")
244
-
245
- for filename in files:
246
- print(f"\nFile: {filename}")
247
-
248
- # Extract thumbnail image
249
- thumb = await client.tcp_client.get_thumbnail(filename)
250
- if thumb and thumb.has_image_data():
251
- print(f"Thumbnail: {len(thumb.get_image_bytes())} bytes")
252
-
253
- # Save thumbnail to disk
254
- thumb.save_to_file_sync(f"{filename}.png")
255
- print(f"Saved thumbnail as {filename}.png")
256
-
257
- asyncio.run(file_operations())
258
- ```
259
-
260
- ---
261
-
262
- <div align="center">
263
-
264
- ## Documentation
265
-
266
- | Resource | Description |
267
- | --- | --- |
268
- | **[Client API Reference](docs/client.md)** | Complete API reference for `FlashForgeClient` and all control modules |
269
- | **[Data Models](docs/models.md)** | Pydantic model documentation for status objects and responses |
270
- | **[Protocols (HTTP/TCP)](docs/protocols.md)** | Understanding the dual-protocol architecture and when to use each |
271
- | **[Advanced Usage](docs/advanced.md)** | Async patterns, error handling, concurrent operations, and best practices |
272
- | **[Complete API Reference](docs/api_reference.md)** | Full class hierarchy and method listing |
273
-
274
- </div>
275
-
276
- ---
277
-
278
- <div align="center">
279
-
280
- ## Development
281
-
282
- | Task | Command | Description |
283
- | --- | --- | --- |
284
- | **Setup Environment** | `python -m venv .venv && .venv\Scripts\activate` | Create and activate virtual environment |
285
- | **Install Dependencies** | `pip install -e ".[dev]"` | Install package with development tools |
286
- | **Run Tests** | `pytest` | Execute test suite |
287
- | **Type Check** | `mypy flashforge/` | Run strict type checking with mypy |
288
- | **Format Code** | `black flashforge/ tests/` | Format code with Black (line length: 100) |
289
- | **Lint** | `ruff check flashforge/ tests/` | Lint code with Ruff |
290
- | **Coverage Report** | `pytest --cov=flashforge --cov-report=html` | Generate test coverage report |
291
- | **Build Package** | `python -m build` | Build distribution packages |
292
- | **Run Pre-commit** | `pre-commit run --all-files` | Execute all pre-commit hooks |
293
-
294
- </div>
295
-
296
- ---
297
-
298
- <div align="center">
299
-
300
- ## License
301
-
302
- **MIT License** - See [LICENSE](LICENSE) for details
303
-
304
- </div>
305
-