Skip to content

Moonraker / Klipper

Moonraker is a web API server for Klipper firmware. PrintStudio’s Moonraker adapter in packages/integrations/adapters/moonraker provides full control of Voron, CoreXY, and other Klipper-based printers.

PrintStudio API
PrinterManager (packages/integrations)
MoonrakerClient
│ HTTP REST (port 7125)
Moonraker Server
Klipper (firmware on Raspberry Pi)
Physical Printer
import { MoonrakerClient } from "@printstudio/integrations/adapters/moonraker";
const client = new MoonrakerClient(
"http://192.168.1.100:7125",
"optional-api-key" // omit for trusted networks
);
// Check connection
const info = await client.getServerInfo();
console.log(info.klippy_connected); // true
// Get temperatures
const temps = await client.getTemperatures();
console.log(`Nozzle: ${temps.extruder.temperature}°C`);
console.log(`Bed: ${temps.heater_bed.temperature}°C`);
// Upload and start print
const gcode = Buffer.from("G28\nG1 X10 Y10\nM84");
await client.uploadFile("test.gcode", gcode);
await client.startPrint("test.gcode");
// Poll progress
const progress = await client.getPrintProgress();
console.log(`${(progress.progress * 100).toFixed(1)}% complete`);
import { PrinterManager } from "@printstudio/integrations";
const manager = new PrinterManager();
manager.registerPrinter("voron-1", {
type: "moonraker",
baseUrl: "http://192.168.1.100:7125",
name: "Voron 2.4 #1",
});
const status = await manager.getStatus("voron-1");
// { state: "idle" | "printing" | "paused" | "error" | "offline",
// progress: 0-100, temperatures: { nozzle: 210, bed: 60 } }
await manager.startJob("voron-1", gcodeBuffer, "part.gcode");
await manager.pauseJob("voron-1");
await manager.resumeJob("voron-1");
await manager.stopJob("voron-1");
Terminal window
MOONRAKER_URL=http://192.168.1.100:7125
MOONRAKER_API_KEY= # optional; set in Moonraker's trusted_clients
OperationAPI Method
Server infogetServerInfo()
Printer infogetPrinterInfo()
TemperaturesgetTemperatures()
Print progressgetPrintProgress()
Upload fileuploadFile(name, data)
Start printstartPrint(filename)
Pause printpausePrint()
Resume printresumePrint()
Cancel printcancelPrint()
List fileslistFiles()
Delete filedeleteFile(filename)
Run G-coderunGcode(code)
Emergency stopemergencyStop()
Restart KlipperrestartKlipper()
Webcam listgetWebcamList()
System infogetSystemInfo()

Moonraker can be configured to require an API key. Add the PrintStudio server to the trusted clients list in moonraker.conf:

[authorization]
trusted_clients:
192.168.1.0/24 # Trust your local subnet
api_key_file: ~/.moonraker_api_key

Then retrieve the key:

Terminal window
ssh pi@192.168.1.100 cat ~/.moonraker_api_key

Set it in .env as MOONRAKER_API_KEY.

Register a Moonraker printer via the API:

Terminal window
curl -X POST http://localhost:8787/api/printers \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"name": "Voron 2.4 #1",
"type": "moonraker",
"machineType": "fdm_large",
"baseUrl": "http://192.168.1.100:7125",
"apiKey": "",
"buildVolume": { "x": 350, "y": 350, "z": 350 }
}'

klippy_connected: false — Klipper is not connected to Moonraker. SSH into the Pi and check sudo systemctl status klipper.

Connection timeout — Ensure the printer is on the same LAN and the Moonraker port (7125) is not firewalled.

File upload fails — Check that the gcodes virtual SD card path is writable: ls -la /home/pi/printer_data/gcodes/.

Emergency stop required — Call await client.emergencyStop(). Note this cuts all stepper and heater power immediately — the printer will need to re-home before the next print.