Barcode API

Generate a Barcode

Batch Generator

Add multiple barcodes and download them as a single PDF or ZPL file.

Printable Label Sheets

Create print-ready label sheets with barcodes sized for thermal printers. Supports Zebra, Brother QL, and DYMO LabelWriter presets.

Create a Sheet

POST /sheets
Content-Type: application/json
# Using a label preset (default TTL: 1 day)
curl -X POST /sheets \
  -H "Content-Type: application/json" \
  -d '{
    "id": "warehouse-42",
    "label_preset": "zebra_2x1",
    "barcodes": [
      {"type": "code128", "data": "SKU-001", "label_text": "Widget A"},
      {"type": "code128", "data": "SKU-002", "label_text": "Widget B"},
      {"type": "qr", "data": "https://example.com/item/3"}
    ]
  }'

# With custom TTL (7 days) and custom dimensions (mm)
curl -X POST /sheets \
  -H "Content-Type: application/json" \
  -d '{
    "id": "custom-labels",
    "ttl": "7d",
    "label_width_mm": 62,
    "label_height_mm": 29,
    "barcodes": [
      {"type": "code128", "data": "ITEM-100", "label_text": "Custom label"}
    ]
  }'

Response (201 Created)

{
  "id": "warehouse-42",
  "url": "/sheets/warehouse-42",
  "barcode_count": 3,
  "label_preset": "zebra_2x1",
  "label_width_mm": 50.8,
  "label_height_mm": 25.4,
  "expires_at": "2026-02-11T13:00:00Z"
}

View & Print

GET /sheets/{id}
GET /sheets/{id}?view=dense

Opens a print-ready HTML page. Click "Print Labels" or press Ctrl+P — each barcode prints on one physical label with zero margins.

Use ?view=dense for a compact view that shows a single label preview with a summary count. Ideal for embedding in iframes. All labels are still included when printing.

Combine with ?preset= to re-layout, e.g. /sheets/{id}?view=dense&preset=zebra_4x6.

Sheet Request Fields

FieldRequiredDescription
idNoCustom ID (alphanumeric, hyphens, dots, max 64 chars). Auto-generated UUID if omitted.
ttlNoHow long the sheet is kept. 1d60d (default: 1d). Accepts days (7d) or hours (48h).
label_preset*Preset key (e.g. zebra_2x1). Required if no raw dimensions.
label_width_mm*Label width in mm. Overrides preset if both given.
label_height_mm*Label height in mm. Overrides preset if both given.
barcodesYesArray of barcode entries (at least one).
barcodes[].typeYesBarcode type (qr, code128, etc.)
barcodes[].dataYesContent to encode
barcodes[].label_textNoCustom text below barcode (empty = no label)

Label Presets

All supported presets are also available as a machine-readable JSON file: GET /presets.json

Preset KeyNameSize (mm)Brand
zebra_4x6Shipping Label101.6 x 152.4Zebra
zebra_2x1Product/Barcode50.8 x 25.4Zebra
zebra_2.25x1.25Retail Shelf57.15 x 31.75Zebra
zebra_3x1Warehouse (narrow)76.2 x 25.4Zebra
zebra_3x2Warehouse76.2 x 50.8Zebra
zebra_4x2Address101.6 x 50.8Zebra
zebra_4x3Pallet/Compliance101.6 x 76.2Zebra
zebra_2x2Square / QR50.8 x 50.8Zebra
zebra_1x1Small Square25.4 x 25.4Zebra
brother_29x90Standard Address29 x 90Brother QL
brother_62x29Small Shipping62 x 29Brother QL
brother_62x100Shipping62 x 100Brother QL
brother_29x42Small Label29 x 42Brother QL
brother_17x54Return Address17 x 54Brother QL
brother_23x23Square23 x 23Brother QL
dymo_89x28Address (30252)89 x 28.6DYMO
dymo_101x59Shipping (30256)101.6 x 58.7DYMO
dymo_54x101Shipping alt (30323)54 x 101.6DYMO
dymo_57x32Multipurpose (30334)57.15 x 31.75DYMO
dymo_25x25Small Square (30332)25.4 x 25.4DYMO
dymo_51x19Return Address (30330)50.8 x 19.05DYMO

Single Barcode

GET /barcode/{type}/{data}?width=200&height=200&dpi=72&label_text=My+Label&format=png

Returns a barcode image. All query params are optional. Set label_text to render custom text below the barcode.

Output Formats

FormatQuery ParamContent-TypeDescription
PNGformat=png (default)image/pngRaster image, ideal for web and print
ZPLformat=zpltext/plainZebra Programming Language, for thermal printers

Examples

# QR code (PNG)
curl -o qr.png /barcode/qr/hello-world

# Code128 with custom size
curl -o code.png "/barcode/code128/ABC-123?width=400&height=150"

# ZPL output for Zebra printers
curl "/barcode/code128/ABC-123?format=zpl"

# ZPL with label text
curl -o label.zpl "/barcode/ean13/5901234123457?format=zpl&label_text=My+Product"

# Embed in HTML
<img src="/barcode/ean13/5901234123457" />

Supported Types

qr code128 code39 code93 ean13 ean8 codabar aztec datamatrix pdf417 2of5

Batch (PDF or ZPL)

POST /barcode/batch
Content-Type: application/json

Returns multiple barcodes as a single file. Defaults to PDF (grid layout); set "format": "zpl" for concatenated ZPL labels.

PDF Example

curl -o barcodes.pdf -X POST /barcode/batch \
  -H "Content-Type: application/json" \
  -d '{
    "page_size": "A4",
    "columns": 3,
    "barcodes": [
      {"type": "qr", "data": "First"},
      {"type": "qr", "data": "Second"},
      {"type": "code128", "data": "ITEM-001"}
    ]
  }'

ZPL Example

curl -o barcodes.zpl -X POST /barcode/batch \
  -H "Content-Type: application/json" \
  -d '{
    "format": "zpl",
    "barcodes": [
      {"type": "code128", "data": "ITEM-001"},
      {"type": "ean13", "data": "5901234123457", "label_text": "EAN Product"}
    ]
  }'
FieldDefaultDescription
formatpdfpdf or zpl
page_sizeA4A4, Letter, or Legal (PDF only)
columns1Grid columns (PDF only)
barcodes[].typerequiredBarcode format
barcodes[].datarequiredContent to encode
barcodes[].widthper typePixel width
barcodes[].heightper typePixel height
barcodes[].dpi72Dots per inch (PNG/PDF only)
barcodes[].label_text""Custom text below barcode (empty = no label)

Configuration

All via environment variables:

VariableDefaultDescription
PORT8080Listen port
HOST0.0.0.0Listen address
CACHE_ENABLEDfalseEnable disk cache
CACHE_DIR/data/cacheCache directory
CACHE_MAX_SIZE_MB1024Max cache size
DEFAULT_DPI72Default DPI
MAX_BATCH_SIZE100Max barcodes per batch
LOG_LEVELinfodebug, info, warn, error
STORAGE_BACKENDmemorySheet storage backend: memory or tigris
BUCKET_NAMETigris bucket name (required when backend is tigris)
SHEET_DEFAULT_TTL24hDefault sheet lifetime (1d)
SHEET_MIN_TTL24hMinimum allowed sheet TTL
SHEET_MAX_TTL1440hMaximum allowed sheet TTL (60d)

Other Endpoints

EndpointDescription
POST /sheetsCreate a printable label sheet
GET /sheets/{id}View/print a label sheet
GET /presets.jsonLabel preset definitions (JSON)
GET /healthzLiveness probe
GET /readyzReadiness probe
GET /swagger/Interactive API docs