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.
Architecture
Section titled “Architecture”PrintStudio API │ ▼PrinterManager (packages/integrations) │ ▼MoonrakerClient │ HTTP REST (port 7125) ▼Moonraker Server │ ▼Klipper (firmware on Raspberry Pi) │ ▼Physical PrinterQuick Start
Section titled “Quick Start”Direct Client Usage
Section titled “Direct Client Usage”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 connectionconst info = await client.getServerInfo();console.log(info.klippy_connected); // true
// Get temperaturesconst temps = await client.getTemperatures();console.log(`Nozzle: ${temps.extruder.temperature}°C`);console.log(`Bed: ${temps.heater_bed.temperature}°C`);
// Upload and start printconst gcode = Buffer.from("G28\nG1 X10 Y10\nM84");await client.uploadFile("test.gcode", gcode);await client.startPrint("test.gcode");
// Poll progressconst progress = await client.getPrintProgress();console.log(`${(progress.progress * 100).toFixed(1)}% complete`);Via PrinterManager
Section titled “Via PrinterManager”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");Configuration
Section titled “Configuration”MOONRAKER_URL=http://192.168.1.100:7125MOONRAKER_API_KEY= # optional; set in Moonraker's trusted_clientsSupported Operations
Section titled “Supported Operations”| Operation | API Method |
|---|---|
| Server info | getServerInfo() |
| Printer info | getPrinterInfo() |
| Temperatures | getTemperatures() |
| Print progress | getPrintProgress() |
| Upload file | uploadFile(name, data) |
| Start print | startPrint(filename) |
| Pause print | pausePrint() |
| Resume print | resumePrint() |
| Cancel print | cancelPrint() |
| List files | listFiles() |
| Delete file | deleteFile(filename) |
| Run G-code | runGcode(code) |
| Emergency stop | emergencyStop() |
| Restart Klipper | restartKlipper() |
| Webcam list | getWebcamList() |
| System info | getSystemInfo() |
API Key Authentication
Section titled “API Key Authentication”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 subnetapi_key_file: ~/.moonraker_api_keyThen retrieve the key:
ssh pi@192.168.1.100 cat ~/.moonraker_api_keySet it in .env as MOONRAKER_API_KEY.
Registering a Printer
Section titled “Registering a Printer”Register a Moonraker printer via the API:
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 } }'Troubleshooting
Section titled “Troubleshooting”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.