2013-12-16 00:47:06 +00:00
|
|
|
.. _sec-api-printer:
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
******************
|
|
|
|
|
Printer operations
|
|
|
|
|
******************
|
2013-12-16 00:47:06 +00:00
|
|
|
|
2013-12-21 12:01:18 +00:00
|
|
|
.. contents::
|
|
|
|
|
|
|
|
|
|
Printer control is mostly achieved through the use of commands, issued to resources reflecting components of the
|
|
|
|
|
printer. OctoPrint currently knows the following components:
|
|
|
|
|
|
|
|
|
|
Print head
|
|
|
|
|
Print head commands allow jogging and homing the print head in all three axes. See :ref:`sec-api-printer-printheadcommand`.
|
|
|
|
|
Heater
|
|
|
|
|
Heater commands allow setting the temperature and temperature offsets for the printer's hotend and bed. Currently
|
|
|
|
|
OctoPrint only supports one hotend heater (this will change in the future). See :ref:`sec-api-printer-heatercommand`.
|
|
|
|
|
Feeder
|
|
|
|
|
Feeder commands allow extrusion/extraction of filament. Currently OctoPrint only supports one feeder (this will
|
|
|
|
|
change in a future version). See :ref:`sec-api-printer-feedercommand`.
|
|
|
|
|
SD card
|
|
|
|
|
SD commands allow initialization, refresh and release of the printer's SD card (if available). See :ref:`sec-api-printer-sdcommand`.
|
|
|
|
|
|
|
|
|
|
.. _sec-api-printer-printheadcommand:
|
2013-12-16 00:47:06 +00:00
|
|
|
|
|
|
|
|
Issue a print head command
|
|
|
|
|
==========================
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
.. http:post:: /api/printer/printhead
|
2013-12-16 00:47:06 +00:00
|
|
|
|
|
|
|
|
Print head commands allow jogging and homing the print head in all three axes. Available commands are:
|
|
|
|
|
|
|
|
|
|
jog
|
|
|
|
|
Jogs the print head (relatively) by a defined amount in one or more axes. Additional parameters are:
|
|
|
|
|
|
|
|
|
|
* ``x``: Optional. Amount to jog print head on x axis, must be a valid number corresponding to the distance to travel in mm.
|
|
|
|
|
* ``y``: Optional. Amount to jog print head on y axis, must be a valid number corresponding to the distance to travel in mm.
|
|
|
|
|
* ``z``: Optional. Amount to jog print head on z axis, must be a valid number corresponding to the distance to travel in mm.
|
|
|
|
|
|
|
|
|
|
home
|
|
|
|
|
Homes the print head in all of the given axes. Additional parameters are:
|
|
|
|
|
|
|
|
|
|
* ``axes``: A list of axes which to home, valid values are one or more of ``x``, ``y``, ``z``.
|
|
|
|
|
|
2013-12-21 12:01:18 +00:00
|
|
|
All of these commands may only be sent if the printer is currently operational and not printing. Otherwise a
|
|
|
|
|
:http:statuscode:`409` is returned.
|
|
|
|
|
|
|
|
|
|
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
|
|
|
|
|
2013-12-16 00:47:06 +00:00
|
|
|
**Example Jog Request**
|
|
|
|
|
|
|
|
|
|
Jog the print head by 10mm in X, -5mm in Y and 0.02mm in Z.
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
POST /api/printer/printhead HTTP/1.1
|
2013-12-16 00:47:06 +00:00
|
|
|
Host: example.com
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
X-Api-Key: abcdef...
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"command": "jog",
|
|
|
|
|
"x": 10,
|
|
|
|
|
"y": -5,
|
|
|
|
|
"z": 0.02
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
**Example Home Request**
|
|
|
|
|
|
|
|
|
|
Home the X and Y axes.
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
POST /api/printer/printhead HTTP/1.1
|
2013-12-16 00:47:06 +00:00
|
|
|
Host: example.com
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
X-Api-Key: abcdef...
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"command": "home",
|
|
|
|
|
"axes": ["x", "y"]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:json string command: The command to issue, either ``jog`` or ``home``.
|
|
|
|
|
:json number x: ``jog`` command: The amount to travel on the X axis in mm.
|
|
|
|
|
:json number y: ``jog`` command: The amount to travel on the Y axis in mm.
|
|
|
|
|
:json number z: ``jog`` command: The amount to travel on the Z axis in mm.
|
|
|
|
|
:json array axes: ``home`` command: The axes which to home, valid values are one or more of ``x``, ``y`` and ``z``.
|
2013-12-21 12:01:18 +00:00
|
|
|
:statuscode 204: No error
|
2013-12-16 00:47:06 +00:00
|
|
|
:statuscode 400: Invalid axis specified, invalid value for travel amount for a jog command or otherwise invalid
|
|
|
|
|
request.
|
2013-12-21 12:01:18 +00:00
|
|
|
:statuscode 409: If the printer is not operational or currently printing.
|
2013-12-16 00:47:06 +00:00
|
|
|
|
2013-12-21 12:01:18 +00:00
|
|
|
.. _sec-api-printer-heatercommand:
|
2013-12-16 00:47:06 +00:00
|
|
|
|
|
|
|
|
Issue a heater command
|
|
|
|
|
======================
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
.. http:post:: /api/printer/heater
|
2013-12-16 00:47:06 +00:00
|
|
|
|
|
|
|
|
Heater commands allow setting the temperature and temperature offsets for the printer's hotend and bed. Available
|
|
|
|
|
commands are:
|
|
|
|
|
|
|
|
|
|
temp
|
|
|
|
|
Sets the given target temperature on the printer's hotend and/or bed. Additional parameters:
|
|
|
|
|
|
|
|
|
|
* ``temps``: Target temperature(s) to set, allowed properties are:
|
|
|
|
|
|
|
|
|
|
* ``hotend``: New target temperature of the printer's hotend in centigrade.
|
|
|
|
|
* ``bed``: New target temperature of the printer's bed in centigrade.
|
|
|
|
|
|
|
|
|
|
offset
|
|
|
|
|
Sets the given temperature offset on the printer's hotend and/or bed. Additional parameters:
|
|
|
|
|
|
|
|
|
|
* ``offsets``: Offset(s) to set, allowed properties are:
|
|
|
|
|
|
|
|
|
|
* ``hotend``: New offset of the printer's hotend temperature in centigrade, max/min of +/-50°C.
|
|
|
|
|
* ``bed``: New offset of the printer's bed temperature in centigrade, max/min of +/-50°C.
|
|
|
|
|
|
2013-12-21 12:01:18 +00:00
|
|
|
All of these commands may only be sent if the printer is currently operational and not printing. Otherwise a
|
|
|
|
|
:http:statuscode:`409` is returned.
|
|
|
|
|
|
|
|
|
|
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
|
|
|
|
|
2013-12-16 00:47:06 +00:00
|
|
|
**Example Target Temperature Request**
|
|
|
|
|
|
|
|
|
|
Set the printer's hotend target temperature to 220°C and the bed target temperature to 75°C.
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
POST /api/printer/heater HTTP/1.1
|
2013-12-16 00:47:06 +00:00
|
|
|
Host: example.com
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
X-Api-Key: abcdef...
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"command": "temp",
|
|
|
|
|
"temps": {
|
|
|
|
|
"hotend": 220,
|
|
|
|
|
"bed": 75
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
**Example Offset Temperature Request**
|
|
|
|
|
|
|
|
|
|
Set the offset for hotend temperatures to +10°C and for bed temperatures to -5°C.
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
POST /api/printer/heater HTTP/1.1
|
2013-12-16 00:47:06 +00:00
|
|
|
Host: example.com
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
X-Api-Key: abcdef...
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"command": "offset",
|
|
|
|
|
"offsets": {
|
|
|
|
|
"hotend": 10,
|
|
|
|
|
"bed": -5
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:json string command: The command to issue, either ``temp`` or ``offset``
|
|
|
|
|
:json object temps: ``temp`` command: The target temperatures to set. Valid properties are ``hotend`` and ``bed``
|
|
|
|
|
:json object offsets: ``offset`` command: The offset temperature to set. Valid properties are ``hotend`` and ``bed``
|
2013-12-21 12:01:18 +00:00
|
|
|
:statuscode 204: No error
|
2013-12-16 00:47:06 +00:00
|
|
|
:statuscode 400: If ``temps`` or ``offsets`` contains a property other than ``hotend`` or ``bed``, the
|
|
|
|
|
target or offset temperature is not a valid number or outside of the supported range, or if the
|
|
|
|
|
request is otherwise invalid.
|
2013-12-21 12:01:18 +00:00
|
|
|
:statuscode 409: If the printer is not operational.
|
2013-12-16 00:47:06 +00:00
|
|
|
|
2013-12-21 12:01:18 +00:00
|
|
|
.. _sec-api-printer-feedercommand:
|
2013-12-16 00:47:06 +00:00
|
|
|
|
2013-12-16 01:11:40 +00:00
|
|
|
Issue a feeder command
|
|
|
|
|
======================
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
.. http:post:: /api/printer/feeder
|
2013-12-16 01:11:40 +00:00
|
|
|
|
|
|
|
|
Feeder commands allow extrusion/extraction of filament. Available commands are:
|
|
|
|
|
|
|
|
|
|
extrude
|
|
|
|
|
Extrudes the given amount of filament. Additional parameters:
|
|
|
|
|
|
|
|
|
|
* ``amount``: The amount of filament to extrude in mm. May be negative to retract.
|
|
|
|
|
|
2013-12-21 12:01:18 +00:00
|
|
|
All of these commands may only be sent if the printer is currently operational and not printing. Otherwise a
|
|
|
|
|
:http:statuscode:`409` is returned.
|
|
|
|
|
|
|
|
|
|
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
|
|
|
|
|
2013-12-16 01:11:40 +00:00
|
|
|
**Example Extrude Request**
|
|
|
|
|
|
|
|
|
|
Extrudes 1mm of filament
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
POST /api/printer/feeder HTTP/1.1
|
2013-12-16 01:11:40 +00:00
|
|
|
Host: example.com
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
X-Api-Key: abcdef...
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"command": "extrude",
|
|
|
|
|
"amount": 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
**Example Retract Request**
|
|
|
|
|
|
|
|
|
|
Retracts 3mm of filament
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
POST /api/printer/feeder HTTP/1.1
|
2013-12-16 01:11:40 +00:00
|
|
|
Host: example.com
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
X-Api-Key: abcdef...
|
2013-12-16 00:47:06 +00:00
|
|
|
|
2013-12-16 01:11:40 +00:00
|
|
|
{
|
|
|
|
|
"command": "extrude",
|
|
|
|
|
"amount": -3
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:json string command: The command to issue, only ``extrude`` is supported right now.
|
|
|
|
|
:json number amount: ``extrude`` command: The amount of filament to extrude/retract in mm.
|
2013-12-21 12:01:18 +00:00
|
|
|
:statuscode 204: No error
|
2013-12-16 01:11:40 +00:00
|
|
|
:statuscode 400: If the value given for `amount` is not a valid number or the request is otherwise invalid.
|
2013-12-21 12:01:18 +00:00
|
|
|
:statuscode 409: If the printer is not operational or currently printing.
|
|
|
|
|
|
|
|
|
|
.. _sec-api-printer-sdcommand:
|
|
|
|
|
|
|
|
|
|
Issue a SD command
|
|
|
|
|
==================
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
.. http:post:: /api/printer/sd
|
2013-12-21 12:01:18 +00:00
|
|
|
|
|
|
|
|
SD commands allow initialization, refresh and release of the printer's SD card (if available).
|
|
|
|
|
|
|
|
|
|
Available commands are:
|
|
|
|
|
|
|
|
|
|
init
|
|
|
|
|
Initializes the printer's SD card, making it available for use. This also includes an initial retrieval of the
|
|
|
|
|
list of files currently stored on the SD card, so after issueing that command a :ref:`retrieval of the files
|
2013-12-22 01:01:48 +00:00
|
|
|
on SD card <sec-api-fileops-retrievelocation>` will return a successful result.
|
2013-12-21 12:01:18 +00:00
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
If OctoPrint detects the availability of a SD card on the printer during connection, it will automatically attempt
|
|
|
|
|
to initialize it.
|
|
|
|
|
|
|
|
|
|
refresh
|
|
|
|
|
Refreshes the list of files stored on the printer's SD card. Will return a :http:statuscode:`409` if the card
|
|
|
|
|
has not been initialized yet (see the ``init`` command and :ref:`SD state <sec-api-printer-sdstate>`).
|
|
|
|
|
|
|
|
|
|
release
|
|
|
|
|
Releases the SD card from the printer. The reverse operation to ``init``. After issuing this command, the SD
|
|
|
|
|
card won't be available anymore, hence and operations targeting files stored on it will fail. Will return a :http:statuscode:`409`
|
|
|
|
|
if the card has not been initialized yet (see the ``init`` command and :ref:`SD state <sec-api-printer-sdstate>`).
|
|
|
|
|
|
|
|
|
|
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
|
|
|
|
|
|
|
|
|
**Example Init Request**
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
POST /api/printer/sd HTTP/1.1
|
2013-12-21 12:01:18 +00:00
|
|
|
Host: example.com
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
X-Api-Key: abcdef...
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"command": "init"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
**Example Refresh Request**
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
POST /api/printer/sd HTTP/1.1
|
2013-12-21 12:01:18 +00:00
|
|
|
Host: example.com
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
X-Api-Key: abcdef...
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"command": "refresh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
**Example Release Request**
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
POST /api/printer/sd HTTP/1.1
|
2013-12-21 12:01:18 +00:00
|
|
|
Host: example.com
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
X-Api-Key: abcdef...
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"command": "release"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:json string command: The command to issue, either ``init``, ``refresh`` or ``release``.
|
|
|
|
|
:statuscode 204: No error
|
|
|
|
|
:statuscode 409: If a ``refresh`` or ``release`` command is issued but the SD card has not been initialized (e.g.
|
|
|
|
|
via ``init``.
|
|
|
|
|
|
|
|
|
|
.. _sec-api-printer-sdstate:
|
|
|
|
|
|
|
|
|
|
Retrieve the current SD state
|
|
|
|
|
=============================
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
.. http:get:: /api/printer/sd
|
2013-12-21 12:01:18 +00:00
|
|
|
|
|
|
|
|
Retrieves the current state of the printer's SD card. For this request no authentication is needed.
|
|
|
|
|
|
|
|
|
|
If SD support has been disabled in OctoPrint's settings, a :http:statuscode:`404` is returned.
|
|
|
|
|
|
|
|
|
|
Returns a :http:statuscode:`200` with an :ref:`SD State Response <sec-api-printer-datamodel-sdstate>` in the body
|
|
|
|
|
upon success.
|
|
|
|
|
|
|
|
|
|
**Example Request**
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
2013-12-22 01:01:48 +00:00
|
|
|
GET /api/printer/sd HTTP/1.1
|
2013-12-21 12:01:18 +00:00
|
|
|
Host: example.com
|
|
|
|
|
|
|
|
|
|
**Example Response**
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: http
|
|
|
|
|
|
|
|
|
|
HTTP/1.1 200 OK
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"ready": true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:statuscode 200: No error
|
|
|
|
|
:statuscode 404: If SD support has been disabled in OctoPrint's config.
|
|
|
|
|
|
|
|
|
|
.. _sec-api-printer-datamodel:
|
|
|
|
|
|
|
|
|
|
Datamodel
|
|
|
|
|
=========
|
|
|
|
|
|
|
|
|
|
.. _sec-api-printer-datamodel-sdstate:
|
|
|
|
|
|
|
|
|
|
SD State Response
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
.. list-table::
|
|
|
|
|
:widths: 15 5 10 30
|
|
|
|
|
:header-rows: 1
|
|
|
|
|
|
|
|
|
|
* - Name
|
|
|
|
|
- Multiplicity
|
|
|
|
|
- Type
|
|
|
|
|
- Description
|
|
|
|
|
* - ``ready``
|
|
|
|
|
- 1
|
|
|
|
|
- Boolean
|
|
|
|
|
- Whether the SD card has been initialized (``true``) or not (``false``).
|