Print to a USB printer from another network
A USB printer stays on its computer. That computer runs the agent. Other networks send a job. They never see the USB port.
For People who need a USB printer to serve a cloud app
Overview
USB has no IP address. A cloud server cannot open a USB port in another building. The computer that has the cable runs the agent, and the cloud server posts a job by printer_code. The USB device stays local.
Install the driver first. If the OS cannot print a test page, the agent cannot either. Then leave that computer on. Sleep looks like AGENT_OFFLINE.
Network printers are the same pattern once they are installed as a queue. You still do not put their private IP in the API request.
Create the job with POST /v1/print-jobs, an Authorization: Bearer header, printer_code, content_type pdf or raw, and exactly one of content or content_url. The free plan is 100 jobs a month on one computer.
Integration steps
- 01
Print a test page on the USB host
Driver first. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 02
Run the agent on that host
Not on the cloud server. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 03
Address it by code
GET /v1/printers. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
- 04
Keep the host awake during service
A laptop lid is a common outage. Use POST /v1/print-jobs with Authorization: Bearer and the printer_code from GET /v1/printers.
Node.js
// Job aimed at the USB printer's queue
const res = await fetch('https://api.printbase.cloud/v1/print-jobs', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRINTBASE_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': idempotencyKey,
},
body: JSON.stringify({
printer_code: Number(process.env.PRINTER_CODE),
content_type: 'pdf',
content: pdf.toString('base64'),
copies: 1,
}),
});
if (!res.ok) throw new Error(`PrintBase ${res.status}: ${await res.text()}`);
const job = await res.json();
// { id: "job_abc", status: "queued" }
Details for this setup
No USB-over-IP claim
This product does not tunnel USB. It submits a print job to the OS queue. The agent prints only what you send; it does not fetch the document from the platform for you.
Several USB printers
Each queue has a code. One agent can report many. The agent prints only what you send; it does not fetch the document from the platform for you.
Questions
Can a phone be the USB host?
The agent is Windows, macOS, or Linux. A phone is not. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Raspberry Pi as the host?
It is a Linux computer. Install CUPS, the printer, and the Linux agent. There is no separate Pi appliance image described here.
Does the cloud see the USB vendor id?
It sees the queue the agent reports, including the name. The call is still POST /v1/print-jobs with a Bearer API key, and HTTP 201 means queued rather than printed.
Unplugging the cable?
The OS marks the printer down. The job fails with a printer or print error, not a network timeout to USB.
Free plan: 100 jobs a month on one computer, no card.