### Build and Start PrusaLink Web Project Commands Source: https://github.com/prusa3d/prusa-link-web/blob/master/README.md Provides commands for building the project for production or starting a development server. Supports various configurations for different printer models (SL1, M1, Mini) and optional authentication methods (http-basic, http-apikey). ```bash npm run build npm run build:mini npm run start npm run start http-basic npm run start http-apikey npm run start:sl1 ``` -------------------------------- ### Install Project Dependencies with npm Source: https://github.com/prusa3d/prusa-link-web/blob/master/README.md Installs all necessary dependencies for the PrusaLink Web project using npm. This is a prerequisite for running any development or build commands. ```bash npm install ``` -------------------------------- ### Start Print Job Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Starts printing a file that exists in the printer storage. ```APIDOC ## POST /api/v1/files/local/{filename} ### Description Starts printing a file that exists in the printer storage. ### Method POST ### Endpoint `/api/v1/files/local/{filename}` ### Parameters #### Path Parameters - **filename** (string) - Required - The name of the file to print. #### Query Parameters - **X-Api-Key** (string) - Required - API key for authentication. ### Request Example ```bash curl -X POST "http://printer-ip/api/v1/files/local/test_print.gcode" \ -H "X-Api-Key: your-api-key" ``` ### Response #### Success Response (204 No Content) Indicates the print job has started successfully. #### Error Response - **401 Unauthorized** - Invalid API key. - **404 Not Found** - The specified file does not exist. - **409 Conflict** - The printer is busy and cannot start a new print job. ``` -------------------------------- ### Build and Development Configuration Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Configuration of webpack for different printer models and development modes using environment variables. Includes details on build commands and custom backend setup. ```APIDOC ## Build and Development Configuration ### Description Configure webpack for different printer models and development modes with environment variables. ### Usage Set environment variables before running build or start commands. #### Environment Variables (Example) - **PRINTER_NAME**: "Original Prusa MINI" - **PRINTER_CODE**: "mini" - **PRINTER_TYPE**: "fdm" | "sla" - **FILE_EXTENSIONS**: Array of strings, e.g., [".gcode", ".bgcode"] - **APP_NAME**: "PrusaLink" - **APP_VERSION**: "3.12.0" - **UPDATE_INTERVAL**: Number (milliseconds) - **WITH_FILES**: Boolean - **WITH_REMOTE_UPLOAD**: Boolean - **WITH_START_PRINT_AFTER_UPLOAD**: Boolean - **WITH_CAMERAS**: Boolean - **WITH_API_KEY_AUTH**: Boolean ### Build Commands - `npm run build`: Build with default config. - `npm run build:mini`: Build for Prusa MINI. - `npm run build:sl1`: Build for SL1 printer. ### Development Server Commands - `npm run start`: Dev server with virtual printer. - `npm run start:mini`: Dev server for MINI config. - `npm run start http-apikey`: Dev with API key auth. ### Custom Backend for Real Printer Testing `BACKEND_URL="http://192.168.1.100/" npm run start:mini` ``` -------------------------------- ### Optional 'Start Print' Checkbox based on Environment Variable Source: https://github.com/prusa3d/prusa-link-web/blob/master/templates/components/upload/remote.html This Jinja2 template snippet conditionally renders a 'Start print after transfer' checkbox. The checkbox is only displayed if the environment variable 'WITH_START_PRINT_AFTER_UPLOAD' is set to true, allowing users to automatically start printing after a file upload. ```jinja2 {% if env.WITH_START_PRINT_AFTER_UPLOAD %} Start print after transfer {% endif %} ``` -------------------------------- ### Run PrusaLink Web with Custom Backend URL Source: https://github.com/prusa3d/prusa-link-web/blob/master/README.md Starts the PrusaLink Web development server with a specific backend URL, allowing testing against a real printer. It uses environment variables to set the backend URL and can be combined with printer-specific configurations. ```bash BACKEND_URL="http://192.168.1.100/" npm run start:mini ``` -------------------------------- ### Define UI Buttons Source: https://github.com/prusa3d/prusa-link-web/blob/master/templates/components/node/file.html Configures the set of available buttons for file management, including details, start print, delete, rename, and download. The 'implemented' and 'WITH_DOWNLOAD_BUTTON' flags control their availability. ```jinja2 {% set buttons = { 'details': {text: 'File details', label: 'proj.details', pc_icon: 'file_details.svg', mobile_icon: 'file_details_light.svg', implemented: true }, 'start': {text: 'Start print', label: 'proj.start', pc_icon: 'print.svg', mobile_icon: 'print_light.svg', implemented: false }, 'delete': {text: 'Delete', label: 'proj.del', pc_icon: 'delete.svg', mobile_icon: 'delete_light.svg', implemented: true }, 'rename': {text: 'Rename', label: 'proj.rename', pc_icon: 'edit.svg', mobile_icon: 'edit_light.svg', implemented: false }, 'download': {text: 'Download', label: 'proj.download', pc_icon: 'download_alt.svg', mobile_icon: 'download_alt_light.svg', implemented: env.WITH_DOWNLOAD_BUTTON } } %} ``` -------------------------------- ### GET /api/v1/storage Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Retrieves a list of available storage devices and their capacity information. ```APIDOC ## GET /api/v1/storage ### Description List available storage devices and their capacity information. ### Method GET ### Endpoint /api/v1/storage ### Parameters #### Headers - **Accept** (string) - Optional - Default: 'application/json' - **Accept-Language** (string) - Optional - Default: 'en' - **X-Api-Key** (string) - Required - API key for authentication. ### Request Example ```bash curl -X GET "http://printer-ip/api/v1/storage" \ -H "Accept: application/json" \ -H "Accept-Language: en" \ -H "X-Api-Key: your-api-key" ``` ### Response #### Success Response (200) - **storage_list** (array) - List of storage devices. - **name** (string) - Name of the storage device. - **type** (string) - Type of storage (e.g., 'LOCAL', 'SDCARD'). - **path** (string) - Mount path of the storage. - **print_files** (integer) - Number of print files. - **system_files** (integer) - Number of system files. - **free_space** (integer) - Free space in bytes. - **total_space** (integer) - Total space in bytes. - **available** (boolean) - Whether the storage is available. - **read_only** (boolean) - Whether the storage is read-only. #### Response Example ```json { "storage_list": [ { "name": "PrusaLink gcodes", "type": "LOCAL", "path": "/local", "print_files": 19216842, "system_files": 4242, "free_space": 1921681142, "total_space": 8589934592, "available": true, "read_only": false }, { "name": "SD Card", "type": "SDCARD", "path": "/sdcard", "available": false, "read_only": false } ] } ``` ``` -------------------------------- ### Webpack Configuration for Printer Models and Development Modes Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Configuration example for webpack.config.js, allowing customization for different printer models (e.g., MINI, SL1) and development modes using environment variables. It defines printer and application-specific settings and provides commands for building and running the development server. ```javascript // webpack.config.js configuration example const config = { PRINTER_NAME: "Original Prusa MINI", PRINTER_CODE: "mini", PRINTER_TYPE: "fdm", // "fdm" or "sla" FILE_EXTENSIONS: [".gcode", ".bgcode"], APP_NAME: "PrusaLink", APP_VERSION: "3.12.0", UPDATE_INTERVAL: 1000, WITH_FILES: true, WITH_REMOTE_UPLOAD: true, WITH_START_PRINT_AFTER_UPLOAD: true, WITH_CAMERAS: false, WITH_API_KEY_AUTH: true }; // Build commands: // npm run build - Build with default config // npm run build:mini - Build for Prusa MINI // npm run build:sl1 - Build for SL1 printer // npm run start - Dev server with virtual printer // npm run start:mini - Dev server for MINI config // npm run start http-apikey - Dev with API key auth // Custom backend for real printer testing: // BACKEND_URL="http://192.168.1.100/" npm run start:mini ``` -------------------------------- ### POST /api/v1/files/local/{fileName} Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Uploads a G-code file to the printer's local storage. Supports an `autoPrint` option to start the print job immediately after successful upload. Includes progress tracking during the upload process. ```APIDOC ### Upload File to Printer Upload G-code files with progress tracking and auto-print functionality. ```javascript import uploadRequest from './helpers/upload_request.js'; // Upload file with progress tracking async function uploadGcode(file, autoPrint = false) { const fileName = file.name; const url = `/api/v1/files/local/${encodeURIComponent(fileName)}`; try { const response = await uploadRequest(url, file, { print: autoPrint, onProgress: (progress) => { console.log(`Upload progress: ${progress.percentage}%`); console.log(`Uploaded: ${progress.loaded}/${progress.total} bytes`); // Update UI progress bar updateProgressBar(progress.percentage); } }); console.log('Upload complete!', response.status); if (autoPrint) { console.log('Print job started automatically'); } return response; } catch (error) { if (error.status === 409) { console.error('File already exists or printer is busy'); } else if (error.status === 401) { console.error('Authentication failed'); } else { console.error('Upload failed:', error.statusText); } throw error; } } // Example: Handle file input and upload document.getElementById('fileInput').addEventListener('change', async (e) => { const file = e.target.files[0]; if (!file) return; const autoPrint = document.getElementById('autoPrintCheckbox').checked; try { await uploadGcode(file, autoPrint); alert('File uploaded successfully!'); } catch (error) { alert('Upload failed: ' + error.statusText); } }); function updateProgressBar(percentage) { const bar = document.querySelector('.progress-bar'); bar.style.width = percentage + '%'; bar.textContent = percentage + '%'; } ``` ``` -------------------------------- ### Start Print Job using cURL Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Initiates a print job for a specified file located in the printer's storage. Requires an API key. A successful request returns HTTP 204 No Content. An error response (HTTP 409 Conflict) is returned if the printer is busy. ```bash curl -X POST "http://printer-ip/api/v1/files/local/test_print.gcode" \ -H "X-Api-Key: your-api-key" # Response: HTTP 204 No Content (success) # Error when printer is busy: # HTTP 409 Conflict { "title": "Printer Busy", "text": "Cannot start print while printer is already printing" } ``` -------------------------------- ### Get File or Folder Information Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Retrieves metadata for files including print time estimates, material requirements, and thumbnail references. ```APIDOC ## GET /api/v1/files/local/{path} ### Description Retrieves metadata for files including print time estimates, material requirements, and thumbnail references. ### Method GET ### Endpoint `/api/v1/files/local/{path}` ### Parameters #### Path Parameters - **path** (string) - Required - The path to the file or folder. #### Query Parameters - **X-Api-Key** (string) - Required - API key for authentication. ### Request Example ```bash curl -X GET "http://printer-ip/api/v1/files/local/examples/test.gcode" \ -H "Accept: application/json" \ -H "X-Api-Key: your-api-key" ``` ### Response #### Success Response (200) - **name** (string) - File name. - **display_name** (string) - Display name of the file. - **read_only** (boolean) - Indicates if the file is read-only. - **size** (integer) - File size in bytes. - **type** (string) - Type of the item (e.g., PRINT_FILE, FOLDER). - **m_timestamp** (integer) - Modification timestamp. - **refs** (object) - References to related resources. - **download** (string) - URL to download the file. - **icon** (string) - URL to the small icon. - **thumbnail** (string) - URL to the original thumbnail. - **meta** (object) - Metadata for print files. - **estimated_print_time** (integer) - Estimated print time in seconds. - **filament_type** (string) - Filament type used. - **layer_height** (number) - Layer height in mm. - **nozzle_diameter** (number) - Nozzle diameter in mm. - **bed_temperature** (integer) - Target bed temperature. - **temperature** (integer) - Target nozzle temperature. #### Response Example ```json { "name": "TEST~1.gco", "display_name": "test.gcode", "read_only": false, "size": 424242, "type": "PRINT_FILE", "m_timestamp": 1648042843, "refs": { "download": "/api/files/local/examples/test.gcode/raw", "icon": "/api/thumbnails/local/examples/test.gcode.small.png", "thumbnail": "/api/thumbnails/local/examples/test.gcode.orig.png" }, "meta": { "estimated_print_time": 2542, "filament_type": "PLA", "layer_height": 0.3, "nozzle_diameter": 0.4, "bed_temperature": 60, "temperature": 215 } } ``` ``` -------------------------------- ### Get Printer Version Information Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Retrieves API version, firmware version, and printer capabilities, including supported upload methods. ```APIDOC ## GET /api/version ### Description Retrieves API version, firmware version, and printer capabilities including supported upload methods. ### Method GET ### Endpoint `/api/version` ### Parameters ### Request Example ```bash curl -X GET "http://printer-ip/api/version" \ -H "Accept: application/json" \ -u "maker:api-key" ``` ### Response #### Success Response (200) - **api** (string) - API version. - **version** (string) - PrusaLink version. - **printer** (string) - Printer firmware version. - **text** (string) - Full version string. - **firmware** (string) - Detailed firmware version. - **sdk** (string) - SDK version. - **capabilities** (object) - Printer capabilities. - **upload-by-put** (boolean) - Indicates if file upload via PUT is supported. #### Response Example ```json { "api": "1.0.0", "version": "0.7.0", "printer": "1.3.1", "text": "PrusaLink 0.7.0", "firmware": "3.10.1-4697", "sdk": "0.7.0", "capabilities": { "upload-by-put": true } } ``` ``` -------------------------------- ### GET /api/v1/cameras/snap Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Captures and retrieves an image from the printer's camera. Supports default or specific camera snapshots. ```APIDOC ## GET /api/v1/cameras/snap ### Description Capture and retrieve an image from the printer's camera. ### Method GET ### Endpoint /api/v1/cameras/snap or /api/v1/cameras/{camera_id}/snap ### Parameters #### Path Parameters - **camera_id** (string) - Optional - The ID of the specific camera to capture from. If not provided, the default camera is used. #### Headers - **X-Api-Key** (string) - Required - API key for authentication. ### Request Example ```bash # Get snapshot from default camera: curl -X GET "http://printer-ip/api/v1/cameras/snap" \ -H "X-Api-Key: your-api-key" \ --output snapshot.png # Get snapshot from specific camera: curl -X GET "http://printer-ip/api/v1/cameras/Z42D4U2NqEX/snap" \ -H "X-Api-Key: your-api-key" \ --output camera_snapshot.png ``` ### Response #### Success Response (200) - Binary PNG image data. #### Error Response (404) No camera available. ``` -------------------------------- ### Get Printer Version Information using cURL Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Retrieves API version, firmware version, and printer capabilities. Requires basic authentication with a username and API key. The response is in JSON format. ```bash curl -X GET "http://printer-ip/api/version" \ -H "Accept: application/json" \ -u "maker:api-key" # Response: { "api": "1.0.0", "version": "0.7.0", "printer": "1.3.1", "text": "PrusaLink 0.7.0", "firmware": "3.10.1-4697", "sdk": "0.7.0", "capabilities": { "upload-by-put": true } } ``` -------------------------------- ### Get Camera Snapshot Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Captures and returns a snapshot image from the printer's camera. You can specify a camera ID or use the default. The output is a PNG image. An error is returned if no camera is available. ```bash # Get snapshot from default camera: curl -X GET "http://printer-ip/api/v1/cameras/snap" \ -H "X-Api-Key: your-api-key" \ --output snapshot.png # Response: Binary PNG image data # Get snapshot from specific camera: curl -X GET "http://printer-ip/api/v1/cameras/Z42D4U2NqEX/snap" \ -H "X-Api-Key: your-api-key" \ --output camera_snapshot.png # No camera available: # HTTP 404 Not Found ``` -------------------------------- ### GET /api/v1/status Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Fetches the current status of the printer, including its state, job progress, and nozzle temperature. Handles various HTTP responses, including 204 No Content. ```APIDOC ### Fetch JSON Data from API Make authenticated GET requests to any API endpoint with automatic error handling. ```javascript import { getJson } from './auth.js'; // Get printer status async function fetchPrinterStatus() { try { const result = await getJson('/api/v1/status'); console.log('Status code:', result.code); console.log('ETag:', result.eTag); console.log('Printer state:', result.data.printer.state); console.log('Job progress:', result.data.job?.progress); console.log('Nozzle temp:', result.data.printer.temp_nozzle); return result.data; } catch (error) { // error.code contains HTTP status code // error.data contains error details from API console.error('API Error:', error.code, error.data?.title); if (error.code === 401) { console.log('Authentication required'); } else if (error.code === 204) { console.log('No content available'); } } } ``` ``` -------------------------------- ### Get Printer Storage Information Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Retrieves a list of all available storage devices connected to the printer, including details on their type, path, file counts, free space, and read-only status. This endpoint requires an API key for authentication and specifies accepted content and language. ```bash curl -X GET "http://printer-ip/api/v1/storage" \ -H "Accept: application/json" \ -H "Accept-Language: en" \ -H "X-Api-Key: your-api-key" # Response: # { # "storage_list": [ # { # "name": "PrusaLink gcodes", # "type": "LOCAL", # "path": "/local", # "print_files": 19216842, # "system_files": 4242, # "free_space": 1921681142, # "total_space": 8589934592, # "available": true, # "read_only": false # }, # { # "name": "SD Card", # "type": "SDCARD", # "path": "/sdcard", # "available": false, # "read_only": false # } # ] # } ``` -------------------------------- ### Get File or Folder Information using cURL Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Retrieves metadata for files stored on the printer, including print time estimates, material requirements, and thumbnail references. Requires an API key for authentication. The response is in JSON format. ```bash curl -X GET "http://printer-ip/api/v1/files/local/examples/test.gcode" \ -H "Accept: application/json" \ -H "X-Api-Key: your-api-key" # Response: { "name": "TEST~1.gco", "display_name": "test.gcode", "read_only": false, "size": 424242, "type": "PRINT_FILE", "m_timestamp": 1648042843, "refs": { "download": "/api/files/local/examples/test.gcode/raw", "icon": "/api/thumbnails/local/examples/test.gcode.small.png", "thumbnail": "/api/thumbnails/local/examples/test.gcode.orig.png" }, "meta": { "estimated_print_time": 2542, "filament_type": "PLA", "layer_height": 0.3, "nozzle_diameter": 0.4, "bed_temperature": 60, "temperature": 215 } } ``` -------------------------------- ### GET /api/v1/transfer Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Monitors ongoing file transfer operations to and from the printer. ```APIDOC ## GET /api/v1/transfer ### Description Monitor ongoing file transfer operations to/from the printer. ### Method GET ### Endpoint /api/v1/transfer ### Parameters #### Headers - **Accept** (string) - Optional - Default: 'application/json' - **X-Api-Key** (string) - Required - API key for authentication. ### Request Example ```bash curl -X GET "http://printer-ip/api/v1/transfer" \ -H "Accept: application/json" \ -H "X-Api-Key: your-api-key" ``` ### Response #### Success Response (200) - Details about ongoing file transfers (structure may vary based on active transfers). #### Error Response (401) Unauthorized. ``` -------------------------------- ### Define Origin Configurations (Jinja2) Source: https://github.com/prusa3d/prusa-link-web/blob/master/templates/components/node/storage.html This Jinja2 template code defines a dictionary named 'origins' which maps origin types (LOCAL, SDCARD, USB) to their display properties. These properties include a user-friendly label, a desktop icon path, and a mobile icon path. This configuration is used to dynamically render origin information within the web interface. ```jinja2 {% set origins = { 'LOCAL': { label: 'Local', pc_icon: 'prusa-link-favicon.svg', mobile_icon: 'prusa-link-favicon.svg' }, 'SDCARD': { label: 'SD Card', pc_icon: 'sd_card.svg', mobile_icon: 'micro_sd_card_light.svg' }, 'USB': { label: 'USB', pc_icon: 'usb-flash-drive-icon.svg', mobile_icon: 'usb-flash-drive-icon-light.svg' } %} {% for key, values in origins %}* ![]({{ pre.countOrRenderAssets(values.pc_icon) | safe }}) ![]({{ pre.countOrRenderAssets(values.mobile_icon) | safe }}) {{ values.label }} {% endfor %} ``` -------------------------------- ### GET /api/v1/cameras Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Retrieves a list of all registered cameras and their current status. ```APIDOC ## GET /api/v1/cameras ### Description Get a list of all registered cameras and their current status. ### Method GET ### Endpoint /api/v1/cameras ### Parameters #### Headers - **Accept** (string) - Optional - Default: 'application/json' - **X-Api-Key** (string) - Required - API key for authentication. ### Request Example ```bash curl -X GET "http://printer-ip/api/v1/cameras" \ -H "Accept: application/json" \ -H "X-Api-Key: your-api-key" ``` ### Response #### Success Response (200) - An array of camera objects. - **camera_id** (string) - Unique identifier for the camera. - **config** (object) - Camera configuration details. - **path** (string) - Path to the camera device. - **name** (string) - Name of the camera. - **driver** (string) - Camera driver type. - **resolution** (string) - Default resolution (e.g., '1280x720'). - **connected** (boolean) - Indicates if the camera is connected. - **detected** (boolean) - Indicates if the camera is detected by the system. - **stored** (boolean) - Indicates if the camera settings are stored. - **linked** (boolean) - Indicates if the camera is linked to a profile. #### Response Example ```json [ { "camera_id": "sh42arta", "config": { "path": "/dev/video0", "name": "Camera L4D", "driver": "V4L2", "resolution": "1280x720" }, "connected": true, "detected": true, "stored": true, "linked": false } ] ``` ``` -------------------------------- ### Configure Upload Sources and Components Source: https://github.com/prusa3d/prusa-link-web/blob/master/templates/components/upload.html This Jinja2 template defines upload sources (local and remote) and conditionally renders corresponding HTML components. It iterates through defined sources and includes their respective components, demonstrating a flexible approach to file uploading. ```jinja2 {# # This file is part of the Prusa Link Web # Copyright (C) 2021 Prusa Research a.s. - www.prusa3d.com # SPDX-License-Identifier: GPL-3.0-or-later #} {% set sources = { 'direct': {text: 'Local storage', label: 'proj.add-from.local', component: 'components/upload/direct.html' }, 'remote': {text: 'Remote URL', label: 'proj.add-from.remote', component: 'components/upload/remote.html' } } %} {% if env.WITH_REMOTE_UPLOAD %} {% for key, values in sources %}* {{ values.text }} {% endfor %} {% else %}* Local storage {% endif %} {% for key, values in sources %} {% include values.component %} {% endfor %} ``` -------------------------------- ### Get Current Job Information Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Retrieves detailed information about the currently running or finished print job. ```APIDOC ## GET /api/v1/job ### Description Retrieves detailed information about the currently running or finished print job. ### Method GET ### Endpoint `/api/v1/job` ### Parameters #### Query Parameters - **X-Api-Key** (string) - Required - API key for authentication. ### Request Example ```bash curl -X GET "http://printer-ip/api/v1/job" \ -H "Accept: application/json" \ -H "X-Api-Key: your-api-key" ``` ### Response #### Success Response (200) - **id** (integer) - Job ID. - **file** (object) - Information about the print file. - **name** (string) - File name. - **path** (string) - File path on the printer. - **size** (integer) - File size in bytes. - **origin** (string) - Origin of the file (e.g., LOCAL). - **date** (integer) - Timestamp of file creation or modification. - **state** (string) - Current state of the print job (e.g., PRINTING, PAUSED, FINISHED, ERROR). - **progress** (object) - Print progress details. - **completion** (number) - Percentage of completion. - **print_time** (integer) - Time elapsed in seconds. - **print_time_left** (integer) - Estimated time remaining in seconds. - **temperatures** (object) - Current and target temperatures. - **tool0** (object) - Nozzle temperatures. - **actual** (number) - Current nozzle temperature. - **target** (number) - Target nozzle temperature. - **bed** (object) - Bed temperatures. - **actual** (number) - Current bed temperature. - **target** (number) - Target bed temperature. - **current_layer** (integer) - The current layer number being printed. - **total_layers** (integer) - The total number of layers in the print job. #### Response Example ```json { "id": 420, "file": { "name": "test_print.gcode", "path": "/local/test_print.gcode", "size": 102400, "origin": "LOCAL", "date": 1648042843 }, "state": "PRINTING", "progress": { "completion": 42.0, "print_time": 526, "print_time_left": 520 }, "temperatures": { "tool0": { "actual": 214.9, "target": 215.0 }, "bed": { "actual": 59.5, "target": 60.0 } }, "current_layer": 50, "total_layers": 200 } ``` ``` -------------------------------- ### Assemble Main Settings Array Source: https://github.com/prusa3d/prusa-link-web/blob/master/templates/pages/settings.html Constructs the main 'settings' array that groups various configuration sections. It includes 'version', 'system version' (conditionally), 'updates' (conditionally), and 'connection' sections. ```jinja {% set settings = [ {'text': 'version', 'label': 'version.title', 'settings': section_version }, {'text': 'system version', 'label': 'sys-version.title', 'settings': [], 'id': 'sys-version', 'condition': env.WITH_SYSTEM_VERSION }, {'text': 'updates', 'label': 'updates.title', 'settings': section_updates, 'condition': env.WITH_SYSTEM_UPDATES }, {'text': 'connection', 'label': 'conn.title', 'settings': section_connectio ``` -------------------------------- ### Virtual Printer Mock Server for Development Source: https://context7.com/prusa3d/prusa-link-web/llms.txt A mock implementation of a development server using Express.js, designed to simulate printer responses for testing purposes without requiring physical hardware. It includes mock endpoints for status updates, file uploads, and job control. ```javascript // tools/server.js mock implementation const express = require('express'); function setupMockServer(app, config) { let mockState = { job: null, printer: { state: 'IDLE', temp_nozzle: 20.0, target_nozzle: 0, temp_bed: 20.0, target_bed: 0 } }; // Mock status endpoint app.get('/api/v1/status', (req, res) => { res.json({ printer: mockState.printer, job: mockState.job, storage: { name: 'LOCAL', path: '/local', read_only: false, free_space: 1000000000 } }); }); // Mock file upload app.put('/api/v1/files/:storage/:filename', (req, res) => { const printAfter = req.headers['print-after-upload'] === '?1'; if (printAfter) { mockState.job = { id: Date.now(), progress: 0, time_printing: 0, time_remaining: 3600 }; mockState.printer.state = 'PRINTING'; } res.status(201).send(); }); // Mock job control app.put('/api/v1/job/:id/pause', (req, res) => { if (mockState.printer.state === 'PRINTING') { mockState.printer.state = 'PAUSED'; res.status(204).send(); } else { res.status(409).json({ title: 'Cannot Pause', text: 'Job is not printing' }); } }); return mockState; } // Start dev server: // npm run start // Open browser to http://localhost:9000 ``` -------------------------------- ### Define Log Download Settings Source: https://github.com/prusa3d/prusa-link-web/blob/master/templates/pages/settings.html Configures the 'logs' section, providing a dropdown to select a log file and a button to download it. This allows users to retrieve log files for debugging or support purposes. ```jinja {% set section_logs = [ {'text': 'select file', 'label': 'logs.select-file', 'type': 'dropdown', 'editable': true, 'value': 'log.log', 'button': {id: 'download-log', label: 'btn.download', text: 'Download'} } ] %} ``` -------------------------------- ### Get Printer Information Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Fetches printer configuration details including name, location, nozzle diameter, serial number, and active features. ```APIDOC ## GET /api/v1/info ### Description Fetches printer configuration details including name, location, nozzle diameter, serial number, and active features. ### Method GET ### Endpoint `/api/v1/info` ### Parameters #### Query Parameters - **X-Api-Key** (string) - Required - API key for authentication. ### Request Example ```bash curl -X GET "http://printer-ip/api/v1/info" \ -H "Accept: application/json" \ -H "X-Api-Key: your-api-key" ``` ### Response #### Success Response (200) - **mmu** (boolean) - Indicates if MMU is attached. - **name** (string) - Printer name. - **location** (string) - Printer location. - **farm_mode** (boolean) - Indicates if farm mode is enabled. - **nozzle_diameter** (number) - Nozzle diameter in mm. - **min_extrusion_temp** (integer) - Minimum extrusion temperature. - **serial** (string) - Printer serial number. - **sd_ready** (boolean) - Indicates if SD card is ready. - **active_camera** (boolean) - Indicates if a camera is active. - **hostname** (string) - Printer hostname. - **port** (string) - Printer serial port path. - **network_error_chime** (boolean) - Indicates if network error chime is enabled. #### Response Example ```json { "mmu": false, "name": "MuadDib", "location": "Arrakis", "farm_mode": false, "nozzle_diameter": 0.4, "min_extrusion_temp": 170, "serial": "CZPX4720X004XC34242", "sd_ready": true, "active_camera": true, "hostname": "prusa-mk3.lan", "port": "/dev/tty", "network_error_chime": true } ``` ``` -------------------------------- ### Get Printer Status and Telemetry Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Retrieves real-time printer status including temperatures, axis positions, job progress, and storage information. ```APIDOC ## GET /api/v1/status ### Description Retrieves real-time printer status including temperatures, axis positions, job progress, and storage information. ### Method GET ### Endpoint `/api/v1/status` ### Parameters #### Query Parameters - **X-Api-Key** (string) - Required - API key for authentication. ### Request Example ```bash curl -X GET "http://printer-ip/api/v1/status" \ -H "Accept: application/json" \ -H "X-Api-Key: your-api-key" ``` ### Response #### Success Response (200) - **printer** (object) - Printer status details. - **state** (string) - Current printer state (e.g., PRINTING, IDLE). - **temp_nozzle** (number) - Current nozzle temperature. - **target_nozzle** (number) - Target nozzle temperature. - **temp_bed** (number) - Current bed temperature. - **target_bed** (number) - Target bed temperature. - **axis_z** (number) - Current Z-axis position. - **flow** (number) - Current print flow percentage. - **speed** (number) - Current print speed percentage. - **fan_hotend** (number) - Hotend fan speed. - **fan_print** (number) - Print fan speed. - **job** (object) - Current print job information. - **id** (integer) - Job ID. - **progress** (number) - Print progress percentage. - **time_remaining** (integer) - Estimated time remaining in seconds. - **time_printing** (integer) - Time elapsed in seconds. - **storage** (object) - Storage information. - **name** (string) - Storage name (e.g., LOCAL). - **path** (string) - Storage path. - **read_only** (boolean) - Whether the storage is read-only. - **free_space** (integer) - Free space in bytes. #### Response Example ```json { "printer": { "state": "PRINTING", "temp_nozzle": 214.9, "target_nozzle": 215.0, "temp_bed": 59.5, "target_bed": 60.0, "axis_z": 0.5, "flow": 95, "speed": 100, "fan_hotend": 420, "fan_print": 420 }, "job": { "id": 420, "progress": 42.0, "time_remaining": 520, "time_printing": 526 }, "storage": { "name": "LOCAL", "path": "/local", "read_only": false, "free_space": 4202335 } } ``` ``` -------------------------------- ### Get Transfer Status Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Monitors the progress and status of ongoing file transfer operations to or from the printer. This endpoint requires an API key and accepts JSON responses. ```bash curl -X GET "http://printer-ip/api/v1/transfer" \ -H "Accept: application/json" \ -H "X-Api-Key: your-api-key" ``` -------------------------------- ### Define Version Settings for FDM Printers Source: https://github.com/prusa3d/prusa-link-web/blob/master/templates/pages/settings.html Defines the configuration settings for the 'version' section specifically for FDM (Fused Deposition Modeling) printers. It includes API, hostname, firmware, server, text, SDK, and frontend version information. This is used for displaying system and printer details. ```jinja {# # This file is part of the Prusa Link Web # Copyright (C) 2021 Prusa Research a.s. - www.prusa3d.com # SPDX-License-Identifier: GPL-3.0-or-later #} {% if env.PRINTER_TYPE == "fdm" %} {% set section_version = [ {'text': 'api ', 'label': 'version.api', "location": "version.api", 'type': 'settings' }, {'text': 'hostname', 'label': 'version.hostname', "location": "version.hostname", 'type': 'settings' }, {'text': 'firmware', 'label': 'version.firmware', "location": "version.firmware", 'type': 'settings' }, {'text': 'server', 'label': 'version.server', "location": "version.server", 'type': 'settings' }, {'text': 'text', 'label': 'version.text', "location": "version.text", 'type': 'settings' }, {'text': 'sdk', 'label': 'version.sdk', "location": "version.sdk", 'type': 'settings' }, {'text': 'frontend', 'label': 'version.fe', 'value': env.APP_VERSION } ] %} {% else %} {% set section_version = [ {'text': 'api ', 'label': 'version.api', "location": "version.api", 'type': 'settings' }, {'text': 'hostname', 'label': 'version.hostname', "location": "version.hostname", 'type': 'settings' }, {'text': 'firmware', 'label': 'version.firmware', "location": "version.firmware", 'type': 'settings' }, {'text': 'text', 'label': 'version.text', "location": "version.text", 'type': 'settings' }, {'text': 'sdk', 'label': 'version.sdk', "location": "version.sdk", 'type': 'settings' }, {'text': 'frontend', 'label': 'version.fe', 'value': env.APP_VERSION } ] %} {% endif %} ``` -------------------------------- ### Virtual Printer Mock Server API Source: https://context7.com/prusa3d/prusa-link-web/llms.txt Provides endpoints for simulating printer responses during development. Useful for testing frontend applications without a physical printer. ```APIDOC ## Virtual Printer Mock Server API ### Description Development server with simulated printer responses for testing without hardware. ### Method GET ### Endpoint `/api/v1/status` ### Description Returns the current status of the virtual printer and job. ### Response #### Success Response (200) - **printer** (object) - Details about the printer's state and temperatures. - **state** (string) - Current printer state (e.g., "IDLE", "PRINTING", "PAUSED"). - **temp_nozzle** (number) - Current nozzle temperature. - **target_nozzle** (number) - Target nozzle temperature. - **temp_bed** (number) - Current bed temperature. - **target_bed** (number) - Target bed temperature. - **job** (object | null) - Details about the current print job, if any. - **id** (number) - Unique job identifier. - **progress** (number) - Print progress percentage. - **time_printing** (number) - Time elapsed in seconds. - **time_remaining** (number) - Estimated time remaining in seconds. - **storage** (object) - Information about the printer's storage. - **name** (string) - Storage name (e.g., "LOCAL"). - **path** (string) - Storage path. - **read_only** (boolean) - Indicates if storage is read-only. - **free_space** (number) - Available free space in bytes. ### Request Example ```json { "printer": { "state": "IDLE", "temp_nozzle": 20.0, "target_nozzle": 0, "temp_bed": 20.0, "target_bed": 0 }, "job": null, "storage": { "name": "LOCAL", "path": "/local", "read_only": false, "free_space": 1000000000 } } ``` --- ### Method PUT ### Endpoint `/api/v1/files/:storage/:filename` ### Description Simulates uploading a file to the printer's storage. Optionally starts printing after upload. ### Parameters #### Path Parameters - **storage** (string) - The storage target (e.g., "LOCAL"). - **filename** (string) - The name of the file to upload. #### Request Headers - **print-after-upload**: `?1` (to trigger printing after upload) ### Response #### Success Response (201) Returns an empty response with status 201. --- ### Method PUT ### Endpoint `/api/v1/job/:id/pause` ### Description Simulates pausing an ongoing print job. ### Parameters #### Path Parameters - **id** (number) - The ID of the job to pause. ### Response #### Success Response (204) Returns an empty response with status 204 if the job was successfully paused. #### Error Response (409) - **title** (string) - "Cannot Pause" - **text** (string) - "Job is not printing" ### Request Example ```json {} // Request body is typically empty for this endpoint ``` ``` -------------------------------- ### Define Connection Settings Source: https://github.com/prusa3d/prusa-link-web/blob/master/templates/pages/settings.html Sets up the 'connection' configuration section. It includes fields for the Prusa Connect URL, connection status, and 3D printer connection status, along with associated buttons for editing and unlinking. ```jinja {% set section_connection = [ {'text': 'PRUSA CONNECT' , 'label': 'conn.prusa-connect-url', 'id': 'conn-prusa-connect-url', 'component': 'conn-status', button: {id: 'edit-connect-set', text: 'set', label: 'btn.connect.link', disabled: false}, editable: true, type: "text" }, {'text': 'connection status' , 'label': 'conn.prusa-connect-status', 'id': 'conn-prusa-connect-status', 'component': 'conn-status', button: {id: 'edit-connect-del', text: 'delete', label: 'btn.connect.unlink', disabled: false} }, {'text': '3D printer connection status' , 'label': 'conn.printer-status', 'id': 'conn-printer-status', 'component': 'conn-status' } ] %} ```