API Preview
API Documentation
Use the rendering endpoint to generate barcodes as SVG (and optionally PNG). The website playground calls the same API via a same-origin proxy.
Quick Start
External API endpoint: /v1/render. An Authorization header with your API token is required.
curl -X POST https://api.xbarcode.ai/v1/render \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"format": "code_128",
"content": "PDN003829102",
"width": 300,
"height": 100,
"color": "#000000",
"bg_color": "#ffffff"
}'
Tip: you can also use GET for quick links:
/v1/render?format=qr_code&content=hello Endpoint
POST https://api.xbarcode.ai/v1/render
GET https://api.xbarcode.ai/v1/render
Request fields are the same for GET and POST. For GET, pass them as query parameters.
Required Header
Authorization: Bearer YOUR_API_TOKEN
Common Parameters
| Name | Type | Required | Notes |
|---|---|---|---|
| format | string | ✅ | Barcode symbology (see table below) |
| content | string | ✅ | Data to encode |
| width | number | Output width in px. Default: 200 (2D) / auto (1D) | |
| height | number | Output height in px. Default: 200 (2D) / 100 (1D) | |
| color | string | Foreground color (hex), e.g. #000000 | |
| bg_color | string | Background color (hex), e.g. #ffffff | |
| rotate | number | Rotation: 0, 90, 180, or 270 | |
| quiet | string | Quiet zone size around the barcode |
Symbology-Specific Parameters
| Name | Type | Applies To | Notes |
|---|---|---|---|
| ec_level | string | QR Code, Micro QR | Error correction: L / M / Q / H. Default: M |
| gs1_format | boolean | QR Code, Data Matrix | Enable GS1 mode encoding. Default: false |
| datamatrix_shape | string | Data Matrix | square or rectangle. Default: square |
| pdf417_cols | number | PDF417 | Number of data columns (1–30) |
| pdf417_ecc_level | number | PDF417 | Error correction level (0–8). Default: 2 |
| aztec_ecc | number | Aztec | Error correction percentage (5–95). Default: 23 |
| maxicode_mode | number | MaxiCode | Mode 2 (US), 3 (Intl), 4 (Standard), 5 (Full ECC), 6 (Reader). Default: 4 |
| bearer | string | 1D Barcodes | Bearer bar style: top_bottom / full |
| bearer_thickness | number | 1D Barcodes | Bearer bar thickness in units |
| bearer_quiet_zone | number | 1D Barcodes | Quiet zone within bearer bar in units |
| output | string | All (except MaxiCode) | Set to matrix to receive raw matrix data as JSON instead of SVG. Not supported for MaxiCode. |
Supported Formats
| Category | Format Key | Aliases |
|---|---|---|
| 2D Matrix | qr_code | qrcode, qr |
| micro_qr | microqr | |
| data_matrix | datamatrix | |
| aztec | — | |
| Stacked | pdf417 | pdf_417 |
| maxicode | — | |
| GS1 | gs1_datamatrix | — |
| gs1_qrcode | — | |
| 1D Linear | code_128 | code128 |
| code_39 | code39 | |
| ean_13 | ean13 | |
| ean_8 | ean8 | |
| upca | — | |
| upce | — | |
| itf | — | |
| codabar | — |
Response
Default — SVG Image
Content-Type:
image/svg+xmlReturns the barcode as an SVG string. Can be embedded directly into HTML or saved as a
.svg file.Matrix Mode — JSON
When
output=matrix, returns JSON:{
"width": 25,
"height": 25,
"data": [0, 0, 0, 1, 1, 1, ...]
} data is a flat array of 0/1 values (row-major). Useful for custom rendering.Error Responses
| Status | Meaning |
|---|---|
| 400 | Encoding error — invalid content for the chosen format (e.g. non-numeric data for EAN-13) |
| 401 | Missing or invalid API token |
| 403 | Subscription expired or insufficient balance |
| 503 | Authentication service temporarily unavailable |