Examples of using the Labelixa API with cURL, Python, C#, Java, Node.js and PHP: ZPL rendering and barcode generation.
A thin official client instead of raw HTTP: quota errors are a distinct class (QuotaExceeded, carrying retry_after), and error messages come from the server verbatim.
from labelixa import Client
c = Client() # anonymous; Client(api_key="lbx_...") for your quota
png = c.render_png("^XA^CF0,60^FO50,50^FDHello^FS^XZ", width_in=4, height_in=6)
open("label.png", "wb").write(png)
report = c.validate("^XA^QQ^FDx^XZ") # structured lint report
epl = c.to_epl("^XA^CF0,60^FO50,50^FDHello^FS^XZ") # ZPL -> EPL2The same surface for Node — zero dependencies (built-in fetch, Node 18+), TypeScript types included.
import { Client } from "labelixa";
const c = new Client(); // anonymous; new Client({ apiKey: "lbx_..." })
const png = await c.renderPng("^XA^CF0,60^FO50,50^FDHello^FS^XZ", { widthIn: 4, heightIn: 6 });
await writeFile("label.png", png);
const report = await c.validate("^XA^QQ^FDx^XZ");
const epl = await c.toEpl("^XA^CF0,60^FO50,50^FDHello^FS^XZ");Claude Desktop, Claude Code and other MCP clients can use Labelixa directly as a tool: ZPL preview, validation and barcode generation. Use our Smithery listing for the zero-install remote server, or run it locally:
{
"mcpServers": {
"labelixa": {
"command": "npx",
"args": ["-y", "labelixa-mcp"],
"env": {"LABELIXA_API_KEY": "lbx_..."}
}
}
}Renders the ZPL block under your cursor inside the editor and lints the file on save, with findings at their real line and column in the Problems panel. Linting never consumes label quota; rendering a preview does, so it only runs on command.
code --install-extension labelixa.labelixa-zplimport requests
r = requests.post("https://api.labelixa.com/v1/printers/8dpmm/labels/4x6/0",
data="^XA^CF0,60^FO50,50^FDHello^FS^XZ")
open("label.png", "wb").write(r.content)
print(r.headers.get("X-Warnings"))const res = await fetch("https://api.labelixa.com/v1/printers/8dpmm/labels/4x6/0", {
method: "POST", body: "^XA^CF0,60^FO50,50^FDHello^FS^XZ"
});
const buf = Buffer.from(await res.arrayBuffer());
require("fs").writeFileSync("label.png", buf);<?php
$ch = curl_init("https://api.labelixa.com/v1/printers/8dpmm/labels/4x6/0");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "^XA^CF0,60^FO50,50^FDHello^FS^XZ");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
file_put_contents("label.png", curl_exec($ch));using var http = new HttpClient();
var zpl = new StringContent("^XA^CF0,60^FO50,50^FDHello^FS^XZ");
var res = await http.PostAsync(
"https://api.labelixa.com/v1/printers/8dpmm/labels/4x6/0", zpl);
res.EnsureSuccessStatusCode();
File.WriteAllBytes("label.png", await res.Content.ReadAsByteArrayAsync());
Console.WriteLine(res.Headers.TryGetValues("X-Warnings", out var w)
? string.Join(", ", w) : "");HttpClient http = HttpClient.newHttpClient();
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.labelixa.com/v1/printers/8dpmm/labels/4x6/0"))
.POST(HttpRequest.BodyPublishers.ofString("^XA^CF0,60^FO50,50^FDHello^FS^XZ"))
.build();
HttpResponse<byte[]> res = http.send(req,
HttpResponse.BodyHandlers.ofByteArray());
Files.write(Path.of("label.png"), res.body());
System.out.println(res.headers().firstValue("X-Warnings").orElse(""));curl "https://api.labelixa.com/v1/barcodes?type=ean13&data=869012345678" > product.pngimport requests
r = requests.get("https://api.labelixa.com/v1/barcodes",
params={"type": "ean13", "data": "869012345678"})
open("product.png", "wb").write(r.content)using var http = new HttpClient();
var url = "https://api.labelixa.com/v1/barcodes?type=ean13&data=869012345678";
File.WriteAllBytes("product.png", await http.GetByteArrayAsync(url));HttpClient http = HttpClient.newHttpClient();
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create(
"https://api.labelixa.com/v1/barcodes?type=ean13&data=869012345678"))
.build();
HttpResponse<byte[]> res = http.send(req,
HttpResponse.BodyHandlers.ofByteArray());
Files.write(Path.of("product.png"), res.body());curl -X POST "https://api.labelixa.com/v1/printers/8dpmm/labels/4x2/" \
--data-binary @labels.zpl -H "Accept: application/pdf" \
-H "X-Page-Size: A4" -H "X-Page-Layout: 2x3" > labels.pdf