Skip to main content

anycubic-lan

Talk to an Anycubic 3D printer in LAN Mode, directly on your network: no Anycubic account, no cloud.

A printer with LAN Mode switched on runs its own MQTT broker. This library performs the printer's handshake to get the broker credentials, connects, asks for state, parses the reports into typed objects, and sends the commands the printer accepts locally. It is fully async and has no cloud code and no bundled certificates or keys.

Tested on a Kobra S1 (firmware 2.7.2.7). Reports from a Kobra X (firmware 2.0.2.2) informed the parser.

Install

pip install anycubic-lan

Python 3.13 or later. Dependencies: aiohttp, paho-mqtt, cryptography.

Switch LAN Mode on at the printer first: Settings → Network → LAN Mode. While LAN Mode is on the printer is not connected to the Anycubic cloud.

Usage

import asyncio

import aiohttp

from anycubic_lan import AnycubicLanClient, AnycubicLanError, handshake


async def main() -> None:
    async with aiohttp.ClientSession() as session:
        info = await handshake(session, "192.168.1.50")  # the printer's IP
    print(info.model_name, info.device_id)

    client = AnycubicLanClient(info)
    client.add_state_listener(
        lambda state: print(state.status, state.temperatures.nozzle, state.job)
    )
    # Fires on changes after connect(): False when lost, True when restored.
    client.add_connection_listener(lambda up: print("restored" if up else "lost"))

    await client.connect()  # subscribes and sends every query
    try:
        for _ in range(4):
            await asyncio.sleep(15)
            await client.query_all()  # the printer answers queries; poll them
        await client.light_on()
    except AnycubicLanError as err:
        print("printer error:", err)
    finally:
        await client.disconnect()


asyncio.run(main())
  • handshake() raises PrinterUnreachableError, LanModeDisabledError, UnsupportedPrinterError, RequestRejectedError or InvalidResponseError (all subclasses of AnycubicLanError).
  • client.state is an immutable PrinterState merged from every report: status, temperatures, fans, speed mode, firmware, the current job (progress, layers, times, task id), ACE boxes and slots, lights, head position, capability flags, camera URL and the last printer error code.
  • Commands: pause(), resume(), stop() (for the current job), light_on(), light_off(), set_light_brightness().
  • The broker credentials rotate when the printer restarts. They are held in memory only; if the connection does not come back, run the handshake again.

Supported printers

Model Model id Status
Kobra S1 20025 Tested (firmware 2.7.2.7, with ACE Pro)
Kobra X 20030 Parser informed by user logs (firmware 2.0.2.2)

Other models that offer LAN Mode with the same handshake should work and are reported as "Anycubic printer (model <id>)". Older models (Kobra 2 and earlier) are detected and refused as unsupported.

Status

Version 0.1.0, alpha. The specification in docs/ comes first; the implementation follows it. Questions to the specification team and their answers are in docs/QUESTIONS.md. See docs/CLEAN-ROOM.md for how this library was written and by whom.

Development

pip install -e ".[test]" ruff mypy
ruff check . && ruff format --check .
mypy --strict src
pytest

Licence

MIT.

Metadata

Release files for anycubic-lan 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anycubic-lan 0.1.1
File Size Uploaded Provenance Actions
anycubic_lan-0.1.1.tar.gz 61.2 kB With provenance Details for anycubic_lan-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for anycubic-lan 0.1.1
File Interpreter ABI Platform Actions
anycubic_lan-0.1.1-py3-none-any.whl Python 3 none any Details for anycubic_lan-0.1.1-py3-none-any.whl

Total release size: 89.1 kB

Release files / anycubic_lan-0.1.1.tar.gz

Download URL anycubic_lan-0.1.1.tar.gz
Size 61.2 kB
Tags Source
SHA-256 checksum
How to use checksums
82d0e2f3018795bec89d20196a1e8c7722c1495ce6bb39e1c094dfc7e5d688c6
BLAKE2b-256 checksum
How to use checksums
b6b49423882d448a3c55b7e73b6018ba52502000bd4f20bb4801fb36c48423b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / anycubic_lan-0.1.1-py3-none-any.whl

Download URL anycubic_lan-0.1.1-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a3776d6a54176b10d2a1514a9fc149c0427a43c5ccf5d3205af3b57f7518d16
BLAKE2b-256 checksum
How to use checksums
14ca86f2bd6fca5d5f4db5087565b3be76c989d8edb69eb076727891a9acd766
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Security for anycubic-lan 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for anycubic_lan-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page