https://github.com/ghosttypes/ff-5mp-api-py
A comprehensive Python library for controlling FlashForge 3D printers
https://github.com/ghosttypes/ff-5mp-api-py
flashforge flashforge-5m
Last synced: about 2 months ago
JSON representation
A comprehensive Python library for controlling FlashForge 3D printers
- Host: GitHub
- URL: https://github.com/ghosttypes/ff-5mp-api-py
- Owner: GhostTypes
- License: mit
- Created: 2025-06-01T19:52:07.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-03-23T21:19:22.000Z (3 months ago)
- Last Synced: 2026-03-24T19:45:53.643Z (3 months ago)
- Topics: flashforge, flashforge-5m
- Language: Python
- Homepage:
- Size: 1.53 MB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# FlashForge Python API
Python library for controlling FlashForge 3D printers with async support for the modern HTTP API and the legacy TCP protocol.
## Supported Printers
| Printer | Support |
| --- | --- |
| Adventurer 5M | Full |
| Adventurer 5M Pro | Full |
| AD5X | Full |
| Adventurer 3 / 4 | Dedicated TCP clients |
## Installation
```bash
pip install flashforge-python-api
```
## Quick Start
Modern LAN-mode HTTP printers require:
- printer IP address
- serial number
- check code (per-printer credential, not returned by discovery)
```python
import asyncio
import os
from flashforge import FlashForgeClient, FiveMClientConnectionOptions, PrinterDiscovery
async def main():
check_code = os.getenv("FLASHFORGE_CHECK_CODE", "").strip()
if not check_code:
print("Set FLASHFORGE_CHECK_CODE before running this example")
return
discovery = PrinterDiscovery()
printers = await discovery.discover()
if not printers:
print("No printers found")
return
printer = printers[0]
if not printer.serial_number:
print("Discovered printer did not report a serial number")
return
options = FiveMClientConnectionOptions(
http_port=printer.event_port,
tcp_port=printer.command_port,
)
async with FlashForgeClient(
printer.ip_address,
printer.serial_number,
check_code,
options=options,
) as client:
status = await client.get_printer_status()
if not status:
return
await client.init_control()
status = await client.get_printer_status()
print(f"Printer: {client.printer_name}")
print(f"State: {status.machine_state if status else 'unknown'}")
await client.control.home_axes()
asyncio.run(main())
```
## Main Entry Points
- `FlashForgeClient`: primary client for modern printers
- `PrinterDiscovery`: recommended discovery API
- `FlashForgeA4Client`: documented TCP client for Adventurer 4 Lite / Pro printers
- `FlashForgeA3Client`: documented TCP client for Adventurer 3 printers
- `FlashForgeTcpClient` and `client.tcp_client`: lower-level TCP access for direct commands and generic legacy workflows
## Capabilities
- printer discovery
- printer status and machine information
- job control
- file listing, uploads, and thumbnails
- temperature and motion control
- LED, camera, and filtration control where supported
- AD5X-specific job and material-station support
## Documentation
- [docs/README.md](docs/README.md)
- [docs/client.md](docs/client.md)
- [docs/protocols.md](docs/protocols.md)
- [docs/api_reference.md](docs/api_reference.md)