Node
A zero-dependency client with TypeScript types and a waitFor helper that polls a job to a terminal state.
npm install @rocketprint/nodeimport RocketPrint from "@rocketprint/node";
const rocketprint = new RocketPrint({ apiKey: process.env.ROCKETPRINT_KEY });
const job = await rocketprint.printJobs.create({
printerId: "6a4738f7462183c7f5d70598",
title: "Order #1042 label",
contentType: "raw_base64",
content: Buffer.from(zpl).toString("base64"),
source: "fulfillment-worker",
}, {
idempotencyKey: "order-1042-label",
});
// Poll until the job reaches completed, failed, or canceled.
const finished = await rocketprint.printJobs.waitFor(job.id);
if (finished.status === "failed") {
logger.error({ jobId: job.id, reason: finished.error }, "label did not print");
}About waitFor
- Polls until the job reaches a terminal state, then resolves with the job.
- It resolves on
failedrather than throwing — a failed print is an outcome to handle, not an exception. - Do not block an HTTP request on it. Print, store the job ID, and check the outcome asynchronously.
- Webhooks will replace polling when they ship; the client will keep the same shape.
Every other language
There is nothing special about the API — one header and a JSON body. Anything that can make an HTTPS request can print.
import base64, os, requests
resp = requests.post(
"https://rocketprint.io/api/v1/print-jobs",
headers={
"X-API-Key": os.environ["ROCKETPRINT_KEY"],
"Idempotency-Key": f"order-{order.id}-label",
},
json={
"printerId": "6a4738f7462183c7f5d70598",
"contentType": "raw_base64",
"content": base64.b64encode(zpl).decode(),
"source": "fulfillment",
},
timeout=10,
)
resp.raise_for_status()
job = resp.json()body, _ := json.Marshal(map[string]any{
"printerId": "6a4738f7462183c7f5d70598",
"contentType": "raw_base64",
"content": base64.StdEncoding.EncodeToString(zpl),
"source": "fulfillment",
})
req, _ := http.NewRequest("POST", "https://rocketprint.io/api/v1/print-jobs", bytes.NewReader(body))
req.Header.Set("X-API-Key", os.Getenv("ROCKETPRINT_KEY"))
req.Header.Set("Idempotency-Key", fmt.Sprintf("order-%s-label", order.ID))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)Generating a client
The public API is described by an OpenAPI 3.1 document, so you can generate a typed client for your language rather than hand-writing one. Full field detail is in the API reference.
