On this page & docs navigation
Quickstart · about 3 steps

Send your first print command

Once the client starts, it exposes a local HTTP / WebSocket service, with the default address http://127.0.0.1:19861. All three steps below use real endpoints, and require no extra wrapper library. If you changed the listening address or port in Settings, adjust to the actual value.

Before you start

Confirm these three things, or the commands below will not run.

The client is running

On Windows, install or unzip it and start it; the program stays in the system tray.

Get the service address

It listens on port 19861 by default; for calls from the LAN, adjust the listening address and port in Settings.

A printer is ready

The target printer is visible in Windows; you will confirm it with GetPrinterList in a moment.

1. Confirm the service is up

Start by requesting GET /api/status. Then pick your language:

curl -X GET "http://127.0.0.1:19861/api/status"

# Returns the service status; the port defaults to 19861 and can be changed in client settings
const base = "http://127.0.0.1:19861";
const r = await fetch(base + "/api/status");
const status = await r.json();
console.log(status);
import json, urllib.request
base = "http://127.0.0.1:19861"
with urllib.request.urlopen(base + "/api/status") as r:
    print(json.load(r))
var base = "http://127.0.0.1:19861";
using var http = new HttpClient();
var json = await http.GetStringAsync(base + "/api/status");
Console.WriteLine(json);
base := "http://127.0.0.1:19861"
resp, err := http.Get(base + "/api/status")
if err != nil { log.Fatal(err) }
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))

If the connection is refused, first check that the client is running and that the address and port match your settings.

2. Fetch the command list

GET /api/commands dynamically returns the allowlist of currently available commands (that is, the public method names of the print service). Fetch the list first, then call it, so command names are never misspelled.

GET /api/commands

→ 返回当前可用的 cmd 名称列表
  常用:GetPrinterList / TemplatePrint / PrintFile / QueuePrint 等
  实际以本次返回为准

3. Send your first command

The general endpoint POST /api/command takes a body of "command name + the JSON parameters for that command". Here, start with GetPrinterList to enumerate printers; it creates no print job.

curl -X POST "http://127.0.0.1:19861/api/command" \
  -H "Content-Type: application/json" \
  -d '{"cmd":"GetPrinterList"}'

# A convenience endpoint is also available: GET /api/printers
const base = "http://127.0.0.1:19861";
const r = await fetch(base + "/api/command", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ cmd: "GetPrinterList" })
});
const result = await r.json();
if (result.code !== 200) console.error(result.error);
import json, urllib.request
base = "http://127.0.0.1:19861"
body = json.dumps({"cmd": "GetPrinterList"}).encode()
req = urllib.request.Request(base + "/api/command", data=body,
                            headers={"Content-Type": "application/json"})
with urllib.request.urlopen(req) as r:
    result = json.load(r)
    print(result["error"] if result["code"] != 200 else result["data"])
var base = "http://127.0.0.1:19861";
using var http = new HttpClient();
var content = new StringContent("{\"cmd\":\"GetPrinterList\"}",
                               Encoding.UTF8, "application/json");
var resp = await http.PostAsync(base + "/api/command", content);
var json = await resp.Content.ReadAsStringAsync();
Console.WriteLine(json);
base := "http://127.0.0.1:19861"
body := strings.NewReader(`{"cmd":"GetPrinterList"}`)
resp, err := http.Post(base + "/api/command", "application/json", body)
if err != nil { log.Fatal(err) }
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)

Equivalent convenience endpoint: GET /api/printers. High-frequency operations can use the convenience endpoint directly, omitting the cmd field.

Response structure

REST and WebSocket both return the same Result structure; to judge the result, look at code, not just the HTTP status.

{
  "code": 200,          // 业务结果码,非 HTTP 状态码
  "error": "success",   // 成功为 success,失败原因读这里
  "data": {}           // 命令返回的数据
}

打印机列表接口保持历史字段不变,新增的 fingerprint and machineId 为增量字段;旧调用方继续读取 printers / primary / detail / source 不受影响。

// GET /api/printers 与 GetPrinterList 返回的 data(兼容历史字段,增量新增指纹)
{
  "printers": ["EPSON TM-T82III", "POSTEK 2108"],  // 历史字段:名称数组
  "primary": "EPSON TM-T82III",                      // 历史字段:默认打印机
  "machineId": "PP-...",                             // 新增:本机机器指纹,用于设备对账
  "detail": [{
    "Name": "EPSON TM-T82III",
    "Driver": "EPSON TM-T82III",
    "Port": "USB001",
    "Status": "就绪",
    "fingerprint": "PR-..."                           // 新增:该打印机的兼容指纹
  }],
  "source": "windows"                                   // 历史字段:打印机信息来源
}

What you can do next

Once you have the printer list, you can send template print jobs, thermal receipts or file print jobs by scenario.

  • Copy as-is by scenario: Examples
  • Switch to a language you know: Multi-language integration
  • Find every endpoint: REST endpoint list
A hand operating a laptop
The client provides an HTTP / WebSocket service on the local machine; business systems call it directly

Next steps