Google Cloud Print replacement for developers: an API and an agent
Google Cloud Print stopped on December 31, 2020. A Google Cloud Print replacement for server-side printing is an agent plus a REST API, not a browser dialog.
For Developers who still find old Cloud Print integrations
Overview
Google's own documentation says Google Cloud Print is no longer supported as of December 31, 2020. From January 1, 2021, devices could not print with it. If your code still calls the old Cloud Print API, that call will not produce paper.
A practical replacement for a server that used to submit a document is: run an agent on a computer that has the printer, and POST /v1/print-jobs with a PDF or raw payload. That is not a Google product and it does not use a Google account.
ChromeOS has its own printing stack now. This page does not claim to be a ChromeOS CUPS replacement. It covers the case Google described for other devices: pick a print service and send the document yourself.
Integration steps
- 01
Install the agent where the printer is
The computer that can already print a test page runs the agent. GET /v1/printers and note the code.
- 02
Keep the API key on a server
Authorization: Bearer. Do not put the key in a browser, a theme, or a public automation log.
- 03
POST the document
content_type pdf or raw, exactly one of content or content_url, plus printer_code.
- 04
Use a stable Idempotency-Key
Retries reuse the key and the body. A reprint uses a new key. A mismatch returns HTTP 409.
Node.js
// Replacement submit for a document that used to go to Cloud Print
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
Source
Google's Cloud Print developer pages and the Chrome Enterprise help article 'Migrate from Cloud Print' state the shutdown date.
What you do not get
No Google account binding, no 'save to Drive' from the old dialog, and no claim that every Cloud Print printer model is supported. Support means: if the OS can print it, the agent can submit a job.
Questions
Is there an official Google replacement API?
Google's help page points people at platform printing or a partner. It does not name PrintBase. You would be choosing this API yourself.
Will my old OAuth tokens work?
No. Those tokens were for a discontinued service. Create a PrintBase API key.
PDF and ticket printers?
PDF uses content_type pdf. Receipt and label languages use raw. Cloud Print's content model is not preserved one-for-one.
Do I need a public IP now?
No. The agent connects outbound. That part is simpler than exposing a printer.
Free plan: 100 jobs a month on one computer, no card.