A Python API for the Creality K1 3D printer
Project description
Creality K1 API
A Python package to communicate with the Creality K1 / K1 Max 3D printer over WebSocket.
Installation
pip install creality_k1_api
Usage
Basic Connection
The client is asynchronous and handles connection management, heartbeats, and message processing. You must provide a callback function that will receive parsed JSON updates from the printer.
import asyncio
from creality_k1_api import CrealityK1Client
def on_new_data(data: dict):
# Handle incoming telemetry updates (temperature, status, progress, etc.)
print("Received update:", list(data.keys()))
async def main():
# K1 WebSocket uses port 9999 by default
client = CrealityK1Client("ws://192.168.10.161:9999", on_new_data)
await client.connect()
# Listen to live updates for 10 seconds
await asyncio.sleep(10)
await client.disconnect()
if __name__ == "__main__":
asyncio.run(main())
Retrieving Timelapse Videos
You can fetch the list of recorded timelapse videos from the printer. The client dynamically parses the printer's hostname to construct complete HTTP download links, and extracts the print start time from the video filename.
import asyncio
from creality_k1_api import CrealityK1Client
async def main():
client = CrealityK1Client("ws://192.168.10.161:9999", lambda data: None)
await client.connect()
if client.is_connected:
# Fetch the list of timelapses (with a 5-second timeout)
videos = await client.get_timelapses(timeout=5.0)
print(f"Found {len(videos)} timelapse videos:")
for video in videos:
print(f"Gcode: {video['gcode']}")
print(f"Download: {video['url']}")
print(f"Start Time: {video.get('start_time')} (UTC)")
print("-" * 50)
await client.disconnect()
if __name__ == "__main__":
asyncio.run(main())
Each timelapse item in the returned list contains:
gcode: The name of the Gcode file that was printed (e.g.Cover_PLA.gcode).url: The full HTTP download URL for the.mp4video (e.g.http://192.168.10.161/downloads/video/1764698892.mp4).timestamp: The Unix timestamp when the print job started (extracted from the filename, e.g.1764698892).start_time: The ISO-8601 UTC formatted datetime representation of the start time (e.g.2025-12-02T18:08:12+00:00).
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file creality_k1_api-0.0.3.tar.gz.
File metadata
- Download URL: creality_k1_api-0.0.3.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e3bdbdcb25e5093900318fa190a7f7b2d6b8652d5ef8ebe72f056b47296910a
|
|
| MD5 |
9c204f407706a6cf72452cb37043c8ba
|
|
| BLAKE2b-256 |
6c96d7f767268a62ee29fa06d5730514cfbfd850fd6aa72712275dd0ba205e1c
|
File details
Details for the file creality_k1_api-0.0.3-py3-none-any.whl.
File metadata
- Download URL: creality_k1_api-0.0.3-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72820a08cfa8117cdaeabc43eb50a312ff936337990bd6d65edc3cef5e8a1388
|
|
| MD5 |
950cc871b3b007f0720e53988e08c132
|
|
| BLAKE2b-256 |
fb038bdd19863f49e20dd244c593f1beadc840fe3a6a228c485c30885e1f9a28
|