通用订单打印网关 — HTTP POST → 热敏打印机
生产地址: https://api.printrelay.es · TCP 客户端: printrelay.es:51902
架构 (2026-05-25): 纯中继管道 — 不做渲染,只做透传。你发 ESC/POS 就转 ESC/POS,发 PDF 就转 PDF。支持两种模式:标准模板模式(兼容 WooCommerce)和纯中转模式(_raw_escpos)。
三步对接:
/wc?token=xxx)# 1. 注册
curl -X POST https://api.printrelay.es/api/register \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"test123"}'
# 2. 登录
curl -X POST https://api.printrelay.es/api/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"test123"}'
# 3. 发送测试打印(标准模板模式)
curl -X POST "https://api.printrelay.es/wc?token=YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"number":"9999","total":"9.99","billing":{"first_name":"Test"},"line_items":[{"name":"Test Item","quantity":1,"total":"9.99"}]}'
所有 API 通过 URL 参数 ?token=xxx 认证(/api/register 和 /api/login 除外)。
| 端点 | 认证方式 |
|---|---|
/api/register | 无(email + password) |
/api/login | 无(email + password) |
其他 /api/* | ?token=TOKEN |
/wc | ?token=TOKEN |
/health | 无 |
注册
POST /api/register
Content-Type: application/json
{"email":"you@example.com","password":"your_password"}
→ {"success":true,"token":"tok_xxxxxxxxxxxxxxxx"}
登录
POST /api/login
Content-Type: application/json
{"email":"you@example.com","password":"your_password"}
→ {"success":true,"token":"tok_xxxxxxxxxxxxxxxx"}
https://api.printrelay.es/panel?token=***
面板功能:添加配对(白名单 Token)· 配置路由(订单来源→目标打印机)· 测试打印 · 模板预览 · 历史记录
GET /api/templates?token=TOKEN → 模板列表
GET /api/templates/{name}?token=TOKEN → 单个模板 JSON
POST /wc?token=YOUR_TOKEN
Content-Type: application/json
{
"number": "2676",
"total": "56.00",
"currency": "EUR",
"date_created": "2026-05-16T19:06:00",
"payment_method": "Barzahlung",
"status": "processing",
"customer_note": "Keine Zwiebeln bitte",
"billing": {
"first_name": "Lukas",
"last_name": "Müller",
"phone": "06802387206",
"email": "lukas@example.com",
"address_1": "Hauptstr. 1",
"city": "Ziersdorf",
"postcode": "3710",
"country": "AT"
},
"line_items": [
{"id":90,"name":"Gebr. Nudel mit Gemüse","sku":"90","quantity":1,"price":"9.90","total":"9.90"},
{"id":55,"name":"Mini Frühlingsrolle (6 Stk.)","sku":"1a","quantity":2,"price":"3.70","total":"7.40"}
]
}
成功:
{"status":"ok","results":[{"client":"餐厅XP80","printer":"XP-80C","ok":true}]}
客户端不在线: HTTP 503 {"error":"Client offline"}
Token 未配对: HTTP 403 {"error":"Unauthorized"}
_raw_escpos(推荐 POS 端使用)你的 POS 系统自己生成 ESC/POS 字节流,Relay 不做任何渲染,直接透传到打印机。
POST /wc?token=YOUR_TOKEN
Content-Type: application/json
{
"ticket_no": "T0001",
"_raw_escpos": true,
"ticket_b64": "<base64 编码的 ESC/POS 字节流(含裁切命令 GS V B)>"
}
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
number | string | 否 | 订单号 |
total | string | 否 | 订单总价 |
currency | string | 否 | 货币代码 (EUR/USD) |
payment_method | string | 否 | 支付方式 |
status | string | 否 | 订单状态 |
customer_note | string | 否 | 客户备注 |
billing.first_name | string | 否 | 客户名 |
billing.phone | string | 否 | 电话 |
line_items[].name | string | 是 | 菜品名 |
line_items[].quantity | int | 是 | 数量 |
line_items[].total | string | 否 | 行总价 |
line_items[].sku | string | 否 | SKU/编码 |