Generate a Barcode
Batch Generator
Add multiple barcodes and download them as a single PDF or ZPL file.
Single Barcode
GET /barcode/{type}/{data}?width=200&height=200&dpi=72&label=true&format=png
Returns a barcode image. All query params are optional. Set label=true to render the data value as text below the barcode.
Output Formats
| Format | Query Param | Content-Type | Description |
|---|---|---|---|
| PNG | format=png (default) | image/png | Raster image, ideal for web and print |
| ZPL | format=zpl | text/plain | Zebra 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=true"
# 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", "label": false}
]
}'
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": true}
]
}'
| Field | Default | Description |
|---|---|---|
format | pdf | pdf or zpl |
page_size | A4 | A4, Letter, or Legal (PDF only) |
columns | 1 | Grid columns (PDF only) |
barcodes[].type | required | Barcode format |
barcodes[].data | required | Content to encode |
barcodes[].width | per type | Pixel width |
barcodes[].height | per type | Pixel height |
barcodes[].dpi | 72 | Dots per inch (PNG/PDF only) |
barcodes[].label | true | Show text label below barcode |
Configuration
All via environment variables:
| Variable | Default | Description |
|---|---|---|
PORT | 8080 | Listen port |
HOST | 0.0.0.0 | Listen address |
CACHE_ENABLED | false | Enable disk cache |
CACHE_DIR | /data/cache | Cache directory |
CACHE_MAX_SIZE_MB | 1024 | Max cache size |
DEFAULT_DPI | 72 | Default DPI |
MAX_BATCH_SIZE | 100 | Max barcodes per batch |
LOG_LEVEL | info | debug, info, warn, error |
Other Endpoints
| Endpoint | Description |
|---|---|
GET /healthz | Liveness probe |
GET /readyz | Readiness probe |
| GET /swagger/ | Interactive API docs |