API Reference

AnyPrint exposes a local HTTP API on 127.0.0.1:3088 (with automatic fallback to ports 3089–3092). All endpoints require a Bearer token. The API is used exclusively by DAXTOP — you only need this reference if you are integrating a custom application.

Base URL

plaintext
http://127.0.0.1:3088

AnyPrint tries port 3088 first. If that port is already in use (e.g., another AnyPrint instance), it falls back to 3089, 3090, 3091, and finally 3092. DAXTOP probes all five ports automatically.

Authentication

Every request must include an Authorization header with a Bearer token:

http
Authorization: Bearer <token>

The token is generated by DAXTOP during setup and stored in the browser's local storage. AnyPrint stores its expected token using electron-store (AES-256-GCM encrypted on disk). A request with a missing or incorrect token returns 401 Unauthorized.

Rate limiting

The API accepts up to 60 requests per minute per IP address. Exceeding this limit returns 429 Too Many Requests.

Endpoints

GET/status

Returns the current status of the AnyPrint service.

Request

http
GET /status HTTP/1.1
Host: 127.0.0.1:3088
Authorization: Bearer <token>

Response 200

json
{
  "status": "ok",
  "version": "1.0.5",
  "port": 3088,
  "printerCount": 1
}

GET/printers

Returns a list of all detected USB thermal printers and their current status.

Request

http
GET /printers HTTP/1.1
Host: 127.0.0.1:3088
Authorization: Bearer <token>

Response 200

json
{
  "printers": [
    {
      "name": "XP-58",
      "vendorId": "0x0416",
      "productId": "0x5011",
      "status": "idle"
    }
  ]
}

Status value

idleReady to receive a print job
printingCurrently executing a print job
errorUSB communication error — reconnect printer

POST/print

Sends a print job to the first available idle printer.

Request

http
POST /print HTTP/1.1
Host: 127.0.0.1:3088
Authorization: Bearer <token>
Content-Type: application/json

{
  "type": "receipt",
  "data": { ... }
}

Request body

FieldTypeMeaning
typestringPrint job type: "receipt", "return", or "test"
dataobjectSale or return data object from DAXTOP (schema defined by DAXTOP API)
printerIdstring (optional)Target a specific printer by vendorId:productId. If omitted, uses the first idle printer.

Response 200

json
{
  "ok": true,
  "printer": "XP-58",
  "jobId": "job_1714060800000"
}

Error responses

StatusErrorMeaning
400Invalid request bodyMissing or invalid fields
401UnauthorizedMissing or wrong Bearer token
409No printer availableAll printers are busy or disconnected
429Too many requestsRate limit exceeded
500Print error: …USB communication failure

WebSocket events

AnyPrint also exposes a WebSocket endpoint at ws://127.0.0.1:3088 for real-time print status updates. DAXTOP subscribes to this stream to show print progress in the UI.

EventDescription
print:startA print job has started
print:donePrint job completed successfully
print:errorPrint job failed — error details included
printer:addedA new USB printer was detected
printer:removedA printer was disconnected