FCKZPL

FCKZPL API Documentation

A Labelary-compatible ZPL rendering API. Drop-in replacement for api.labelary.com.

Contents

Labelary-Compatible API

These endpoints follow the same URL pattern as the Labelary API, making FCKZPL a drop-in replacement.

POST /v1/printers/{dpmm}/labels/{width}x{height}/{index}/

Render ZPL to a PNG image (or PDF with the appropriate Accept header).

URL Parameters

ParameterDescription
{dpmm} Print density. One of: 6dpmm (152 DPI), 8dpmm (203 DPI), 12dpmm (300 DPI), 24dpmm (600 DPI)
{width}x{height} Label dimensions in inches (e.g. 4x6, 3.5x5)
{index} Label index, 0 for first label

Request Body

ZPL source code. Supported content types:

Content-TypeDescription
application/x-www-form-urlencoded ZPL text as the raw body (URL-encoded). This is what Labelary uses.
text/plain Plain ZPL text

Headers

HeaderEffect
Accept: image/png Return PNG image (default)
Accept: application/pdf Return PDF document

Response

image/png (default) or application/pdf depending on Accept header.

Example

curl -X POST https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/ \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "^XA^FO50,50^A0N,50,50^FDHello World^FS^XZ" \
  --output label.png

To get PDF output:

curl -X POST https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/ \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Accept: application/pdf" \
  -d "^XA^FO50,50^A0N,50,50^FDHello World^FS^XZ" \
  --output label.pdf
GET /v1/printers/{dpmm}/labels/{width}x{height}/{index}/?zpl=...

Same as the POST endpoint, but with ZPL provided as a query parameter. Useful for embedding labels in <img> tags.

Query Parameters

ParameterDescription
zpl URL-encoded ZPL source code

Example

curl "https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/?zpl=%5EXA%5EFO50%2C50%5EA0N%2C50%2C50%5EFDHello%5EFS%5EXZ" \
  --output label.png

Embed in HTML:

<img src="https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/?zpl=^XA^FO50,50^A0N,50,50^FDHello^FS^XZ" />

Internal Render API

These endpoints power the FCKZPL web viewer and offer more configuration options than the Labelary-compatible API.

POST /api/render

Render ZPL to a PNG image with full control over label parameters.

Query Parameters

ParameterDefaultDescription
width 4 Label width (in the specified unit)
height 6 Label height (in the specified unit)
unit Inches Unit of measurement: Inches, Mm, Cm, Dots
dpi 203 Print resolution: 152, 203, 300, 600
renderMode Bicolor Rendering mode: Bicolor (black & white) or Greyscale

Request Body

ZPL text as text/plain, or multipart/form-data with:

FieldDescription
zpl ZPL source code (text field)
fonts Optional font files (.ttf, .tte, .otf)

Response

image/png

Example

curl -X POST "https://fckzpl.com/api/render?width=4&height=6&unit=Inches&dpi=203&renderMode=Bicolor" \
  -H "Content-Type: text/plain" \
  -d "^XA^FO50,50^A0N,50,50^FDHello World^FS^XZ" \
  --output label.png

With custom fonts (multipart):

curl -X POST "https://fckzpl.com/api/render?width=4&height=6&dpi=203" \
  -F "zpl=^XA^CWA,R:MYFONT.TTF^FO50,50^AAN,40,40^FDCustom Font^FS^XZ" \
  -F "fonts=@MyFont.ttf" \
  --output label.png
POST /api/render/pdf

Render ZPL to a PDF document. Accepts the same parameters as /api/render plus rotation.

Additional Query Parameters

ParameterDefaultDescription
rotation 0 Rotation in degrees: 0, 90, 180, 270

Response

application/pdf

Example

curl -X POST "https://fckzpl.com/api/render/pdf?width=4&height=6&dpi=203&rotation=0" \
  -H "Content-Type: text/plain" \
  -d "^XA^FO50,50^A0N,50,50^FDHello World^FS^XZ" \
  --output label.pdf

Migration from Labelary

Drop-in replacement: Simply replace api.labelary.com with your FCKZPL server address in your existing code.

If your application currently calls the Labelary API like this:

curl -X POST http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/ \
  -d "^XA^FO50,50^A0N,50,50^FDHello^FS^XZ" \
  --output label.png

Just change the host:

curl -X POST https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/ \
  -d "^XA^FO50,50^A0N,50,50^FDHello^FS^XZ" \
  --output label.png

The URL pattern, request format, and response format are identical. Both application/x-www-form-urlencoded and text/plain content types are supported. PDF output via Accept: application/pdf header works the same way.

Limits 10 MB

The maximum request body size is 10 MB. This applies to all endpoints (ZPL text, font uploads, etc.).

If you need to render very large ZPL programs or upload many custom fonts, consider splitting them into separate requests.

Examples

Render a shipping label (PNG)

curl -X POST https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/ \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "^XA
^FO50,50^GB700,1100,3^FS
^FO50,50^A0N,60,60^FDShipping Label^FS
^FO50,150^BY3^BCN,100,Y,N,N^FD>:1234567890^FS
^FO50,300^A0N,40,40^FDJohn Doe^FS
^FO50,360^A0N,40,40^FD123 Main Street^FS
^FO50,420^A0N,40,40^FDNew York, NY 10001^FS
^XZ" \
  --output shipping-label.png

Get PDF output

curl -X POST https://fckzpl.com/v1/printers/12dpmm/labels/4x6/0/ \
  -H "Accept: application/pdf" \
  -d "^XA^FO50,50^A0N,50,50^FDHello PDF^FS^XZ" \
  --output label.pdf

Embed in an HTML page

<!-- Direct image embedding via GET -->
<img src="https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/?zpl=^XA^FO50,50^A0N,50,50^FDHello^FS^XZ" alt="Label" />

JavaScript fetch

const response = await fetch('/v1/printers/8dpmm/labels/4x6/0/', {
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    body: '^XA^FO50,50^A0N,50,50^FDHello World^FS^XZ'
});
const blob = await response.blob();
const url = URL.createObjectURL(blob);
document.getElementById('label').src = url;

Python requests

import requests

zpl = "^XA^FO50,50^A0N,50,50^FDHello World^FS^XZ"
response = requests.post(
    "https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/",
    data=zpl,
    headers={"Content-Type": "application/x-www-form-urlencoded"}
)
with open("label.png", "wb") as f:
    f.write(response.content)

C# HttpClient

using var client = new HttpClient();
var zpl = "^XA^FO50,50^A0N,50,50^FDHello World^FS^XZ";
var content = new StringContent(zpl, System.Text.Encoding.UTF8, "application/x-www-form-urlencoded");
var response = await client.PostAsync("https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/", content);
var png = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes("label.png", png);

// PDF output
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new("application/pdf"));
var pdfResponse = await client.PostAsync("https://fckzpl.com/v1/printers/8dpmm/labels/4x6/0/", content);
File.WriteAllBytes("label.pdf", await pdfResponse.Content.ReadAsByteArrayAsync());

Internal API with greyscale rendering

curl -X POST "https://fckzpl.com/api/render?width=100&height=60&unit=Mm&dpi=300&renderMode=Greyscale" \
  -H "Content-Type: text/plain" \
  -d "^XA^FO50,50^A0N,50,50^FDMetric Label^FS^XZ" \
  --output label-greyscale.png