Skip to main content

Protocol specification

info

The protocol is available on TCP/IP port 10001.

The protocol is line-based, meaning each request and each response is transmitted as a single line of text.

All requests are executed in order, and each request generates exactly one response. After sending a request, it is important to read the entire response. Otherwise, the TCP/IP connection will stall when the transmit buffer in the printer is full. Alternatively, responses can be suppressed by prefixing the request with a tile character.

Line termination

A line may be terminated using any of the following:

  • LF — ASCII line feed, decimal 10, hex 0A
  • CR — ASCII carrige return, decimal 13, hex 0D
  • CR+LF

Character encoding

All content must be encoded using UTF-8.

Request format

The format of the request is a method name, followed by an optional parameter as a JSON value, separated by a single space.

If a client does not need to know whether a request is successful or not, the request can be prefixed with a tilde character (~), e.g. "~trigger". This will cause the printer to omit sending a response, and instead terminate the connection on error.

Reponse format

The format of a response is a single line consisting of a status code followed by a single space and a JSON variable. The status code is one of the following:

Status codeDescription
OKThe request was successful.
METHOD_NOT_FOUNDThe requested method does not exist.
INVALID_PARAMSThe parameters are invalid, e.g. it could be invalid JSON, the wrong type, or be missing required keys.
REQUEST_FAILEDThe request failed, e.g. a request for an object that doesn't exist, or the printer is in the wrong state, etc.

The returned variable can be of any valid JSON type, e.g. null, a string, an object, etc. For successful requests (with status OK), the type of the response depends on the request. For unsuccessful requests, the type is always a string.

Responses that do not have a meaningful return value will still return null. For example:

OK null