Host software and print farms
📍 Where we are: Part III · The Software Stack — Chapter 8 of 16. The slicer produced G-code and the CAD chapter produced the model; now we look at the software that sits next to the printer, accepts the file, starts the job and reports progress.
Think of a restaurant. The cook (the firmware) only knows how to cook one dish at a time, exactly as written on the ticket. The host software is the waiter and the order system: it takes your order (the G-code file), puts it in a queue, tells the cook to start, and lets you check on it from your table, a phone, or from across town. A print farm is a restaurant with twenty cooks and one manager who sees every ticket. And because the waiter will do what anyone at the door asks, you need to decide who is allowed in.
What this chapter covers
We cover the two main open host stacks, OctoPrint and the Klipper family (Moonraker with the Mainsail or Fluidd web interfaces); how their HTTP APIs work, with a runnable client; the open tools that manage many printers; and the security rules that matter, because a printer host can heat a nozzle and move motors for whoever is allowed to talk to it.
Why a host at all
Firmware (see Firmware) executes G-code on a microcontroller. A small computer beside it, the host, adds what a microcontroller is bad at: a web server, file storage, a camera, a job history, and a network stack. Klipper makes this split explicit: its README describes combining "the power of a general purpose computer with one or more micro-controllers" [1].
OctoPrint
OctoPrint is a web interface for controlling consumer 3D printers; its repository is licensed AGPL-3.0, is a Python project, and links an official plugin repository from its README [2].
Its REST API
OctoPrint's documentation shows three ways to authenticate an API request: an X-Api-Key header, an Authorization: Bearer header, or an apikey query parameter that it says is for testing only [3]. For example, GET /api/version with the header returns a JSON object with api, server and text keys [4], and POST /api/job with the body {"command": "start"} starts the selected job, returning 204 on success and 409 if a job is already active or the printer is not operational [5]. Two things from the authentication page matter for safety: when access control is on, an anonymous request is denied with 403 for any endpoint other than login, and when access control is disabled, anonymous requests get full admin rights [3].
# Requires a running OctoPrint and an API key (see the Application Keys workflow in its docs)
curl -H "X-Api-Key: $OCTOPRINT_KEY" http://HOST:5000/api/version
I did not have an OctoPrint instance to test against, so this command and the response shape come from the documentation, not from a run. The port in the example is a placeholder for your own address.
The Klipper stack: Klipper, Moonraker, Mainsail, Fluidd
Klipper is GPL-3.0 firmware that combines a general-purpose computer with one or more microcontrollers [1]. It does not try to be a web server. Moonraker is a Python 3 web server (built on Tornado, GPL-3.0) that exposes APIs for Klipper; it ships no user interface and talks to the Klippy host over a Unix domain socket [6]. The clients are separate projects: Mainsail (GPL-3.0; file manager and editor, print history, a job queue, multiple webcams, bed-mesh visualisation) [7] and Fluidd (GPL-3.0; usable on desktop, tablet and phone, can be installed with the KIAUH helper) [8]. Moonraker's README mentions ready-made Raspberry Pi images, MainsailOS and FluiddPi, that bundle the stack [6]. Prusa has its own open host interface: PrusaLink Web is a GPL-3.0 browser interface for Prusa printers whose behaviour is defined through an OpenAPI specification [9].
Two host stacks and a fleet layer: UIs and farm tools speak to an API server, which talks to the firmware.
Original diagram by the authors, created with AI assistance.
Moonraker's API
Moonraker offers its API over HTTP and over JSON-RPC (a message format) on a WebSocket; file transfers are HTTP-only and the WebSocket is how a client receives live events. Successful HTTP responses are wrapped as {"result": ...} [10]. Documented endpoints include GET /printer/info, POST /printer/gcode/script with a JSON body like {"script": "G28"}, POST /printer/print/start?filename=..., POST /printer/print/pause, POST /printer/print/cancel and POST /printer/emergency_stop [11]. GET /server/info returns, among other fields, klippy_state, one of disconnected, startup, ready, error or shutdown [12]. Moonraker's default HTTP port is 7125 [13].
Klipper itself says it does not aim to support every G-code command, and that its terminal output is meant for humans: software that controls Klipper should use the API server rather than parse console text [14].
A status client you can run
The script below uses only the Python standard library. It reads /server/info, then /printer/info if Klipper reports ready, and sends an X-Api-Key header only if you give it a key.
import json
import sys
import urllib.request
def get(base, path, api_key=None):
req = urllib.request.Request(base + path)
if api_key:
req.add_header("X-Api-Key", api_key)
with urllib.request.urlopen(req, timeout=5) as resp:
return json.load(resp)["result"] # successful replies are wrapped in {"result": ...}
def main():
base = sys.argv[1] if len(sys.argv) > 1 else "http://localhost:7125"
key = sys.argv[2] if len(sys.argv) > 2 else None
server = get(base, "/server/info", key)
print("klippy_state:", server["klippy_state"], "| moonraker", server["moonraker_version"])
if server["klippy_state"] == "ready":
printer = get(base, "/printer/info", key)
print("printer state:", printer["state"], "-", printer["state_message"])
main()
Run status: not run against a real Moonraker; I had no Klipper machine. I ran it against a small local mock HTTP server that returns the response shapes quoted in Moonraker's documentation. The mock returned status 401 without the key, and the script printed klippy_state: ready | moonraker mock and printer state: ready - Printer is ready with the key. That tests the client logic and header handling, not Moonraker's behaviour. Run it against your own printer first with read-only calls like these before you try anything that moves the machine; G28 (home all axes) will move it.
Many printers: open fleet tools
A farm needs a queue, a view of every machine, and inventory. The open options I could verify:
| Project | Licence | What it does |
|---|---|---|
| FDM Monster | AGPL-3.0 | Farm platform with a printer grid; backends are OctoPrint, Klipper via Moonraker, PrusaLink and Bambu Lab in LAN mode; can send a G-code file to several printers; forked from OctoFarm in 2021 [15] |
| OctoFarm | AGPL-3.0 | The original unifier of multiple OctoPrint instances, from which FDM Monster was forked [15][16] |
| Spoolman | MIT | Self-hosted filament inventory with a REST API; integrates with Moonraker front ends and OctoPrint [17] |
| Obico server | AGPL-3.0 | Self-hostable server (Docker) with deep-learning print-failure detection [18] |
Mainsail lists a job queue among its features [7], but that is a queue on one machine; fleet tools such as FDM Monster instead let you send a file to one or several printers from a single screen. I did not evaluate how well any of these scale, so treat "farm" here as the architecture, not a tested capacity.
Security
These services control heaters and motors, so treat them as you would a remote control for machinery.
- Stay on a private network. OctoPrint's security policy says it is meant to run on a secure private network and calls exposure to the public internet a severe misconfiguration [19].
- Authenticate. OctoPrint with access control disabled grants anonymous requests admin rights [3]. Moonraker's
trusted_clientsoption lists addresses that get full API access, and the default trusts nobody; its documentation advises IP ranges over domain names;cors_domains = *is described as for client developers, not for production; andforce_loginsrequires login whenever a user exists [13]. - Use a reverse proxy for remote access. Moonraker's documentation calls running behind a proxy the recommended setup [13]. I am not prescribing a specific remote-access product; a VPN into your own network avoids exposing the service at all.
- Keep cameras in mind. A webcam feed leaves your workshop if the host is exposed.
Why it matters
The host is where "I have a printer" becomes "I have a networked machine". It is also the layer where open-source choices differ most: how the API is documented, how access is controlled, and how many printers one person can look after.
In the real world
For one printer, the main choice is OctoPrint versus a Klipper stack with Mainsail or Fluidd; the choice usually follows the firmware you picked. For a handful or more, a fleet tool adds the missing queue and inventory.
Key terms
- Host — the small computer beside a printer that runs the web interface, file storage and job control.
- REST API — a web interface in which URLs and HTTP methods (GET, POST) name resources and actions.
- JSON-RPC — a message format in which a client sends a method name and parameters, often over a WebSocket.
- API key — a secret string sent with each request to prove the client may use the API.
- Moonraker — the Python web server that exposes Klipper's functions through HTTP and WebSocket APIs.
- Mainsail / Fluidd — open web interfaces for Klipper that talk to Moonraker.
- Job queue — an ordered list of files waiting to print.
- Print farm — many printers managed together, usually with a shared view and queue.
- Reverse proxy — a front-end web server that forwards requests to an internal service, often adding encryption and login.
Where this leads
Every tool in this chapter moves files around. The next chapter looks at the files themselves: File formats and open data.