xBarcode API Reference
All responses are SVG images (Content-Type: image/svg+xml).
Request Format
GET /{symbology}/{content}?{parameters}| Component | Description |
|---|---|
symbology | Barcode type (e.g., qr, code128, pdf417) |
content | Data to encode (URL-encode if necessary) |
parameters | Optional query parameters to customize output |
Common Parameters
The following parameters apply to almost all barcode types:
| Parameter | Type | Default | Description |
|---|---|---|---|
width | number | (auto) | Force output width (pixels/units) |
height | number | (auto) | Force output height |
rotate | number | 0 | Rotation angle (0, 90, 180, 270) |
margin | number | 0 | Quiet zone margin (in modules). Alias: m |
fg | hex | 000000 | Foreground color (barcode bars) |
bg | hex | ffffff | Background color |
1D Barcodes
Supported symbologies: code128, ean13, ean8, upca, upce, code39, code93, codabar, itf, msi, and more.
Example:
GET /code128/ABC-1234?height=80Bearer Bars
1D barcodes support optional bearer bars (horizontal support bars), commonly used for ITF-14 or visual styling.
| Parameter | Type | Default | Description |
|---|---|---|---|
bearer | string | none | Shape: top_bottom, top_only, bottom_only |
thickness | number | 0 | Bearer bar thickness (modules/pixels) |
quiet | number | 10 | Gap between barcode and bearer bars |
Examples:
GET /itf/123456?bearer=top_bottom&thickness=5 (ITF-14 style)
GET /code128/TEST?bearer=top_bottom&thickness=2 (Visual styling)2D Barcodes
QR Code
Endpoint: /qr/{content}
| Parameter | Type | Default | Description |
|---|---|---|---|
ecl | string | M | Error correction level: L, M, Q, H |
version | number | (auto) | Fixed version (1–40). Omit for auto-sizing. |
Example:
GET /qr/https://example.com?ecl=HGS1 QR Code
Endpoint: /gs1_qr/{content}
Generates GS1-compliant QR Codes using FNC1 mode. See GS1 Guide for details.
DataMatrix
Endpoint: /datamatrix/{content}
| Parameter | Type | Default | Description |
|---|---|---|---|
shape | string | square | Symbol shape: square or rect |
GS1 DataMatrix
Endpoint: /gs1_datamatrix/{content}
Generates GS1-compliant DataMatrix with FNC1 prefix. See GS1 Guide for details.
PDF417
Endpoint: /pdf417/{content}
| Parameter | Type | Default | Description |
|---|---|---|---|
cols | number | (auto) | Number of data columns (1–30) |
rows | number | (auto) | Number of rows (3–90) |
ecl | number | (auto) | Error correction level (0–8) |
compact | boolean | false | Set true for Compact/Truncated PDF417 |
Aztec Code
Endpoint: /aztec/{content}
| Parameter | Type | Default | Description |
|---|---|---|---|
ecl | number | ~23 | Minimum error correction percentage (0–100) |
layers | number | (auto) | Force specific number of layers |
MaxiCode
Endpoint: /maxicode/{content}
| Parameter | Type | Default | Description |
|---|---|---|---|
mode | number | 4 | MaxiCode mode (2, 3, 4, 5) |
Error Handling
When barcode generation fails (data too long, invalid characters, etc.), the server returns:
| Field | Value |
|---|---|
| Status Code | 400 Bad Request |
| Response Body | Plain text error message (e.g., "Numeric limit exceeded") |