Barcode Generator API
Create Code 128 barcodes for labels, SKUs and shipping with a single request. SVG with human-readable text or PNG, custom height, width and colours.
The Barcode API generates Code 128 barcodes, the most widely used linear barcode for shipping labels, warehouse SKUs, invoices and internal asset tags. Send GET /v1/barcode?text=ABC-12345 and receive a crisp SVG image; add format=png for a bitmap.
The encoder automatically switches between Code 128 set B (all printable ASCII characters) and set C (pairs of digits) so long numeric runs produce a compact barcode, and it calculates the check digit for you. The text can be up to 80 printable ASCII characters; accented or non-Latin characters are rejected with a clear error.
Options: height of the bars (20–600 px, default 80), module_width (1–10 px per narrow bar, default 2), foreground color and background, and show_text=false to hide the human-readable line printed under the SVG barcode (PNG output contains the bars only).
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
text | body|query | string | yes | Content to encode: printable ASCII, max 80 characters. | |
format | body|query | string | no | svg | svg or png. |
height | body|query | number | no | 80 | Bar height in pixels (20–600). |
module_width | body|query | number | no | 2 | Width of the narrowest bar in pixels (1–10). |
color | body|query | string | no | 000000 | Bar colour (hex or basic colour name). |
background | body|query | string | no | ffffff | Background colour. |
show_text | body|query | boolean | no | true | Print the text under the barcode (SVG only). |
Example
curl "https://apibox.io.vn/v1/barcode?text=ABC-12345&height=80" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o outputconst res = await fetch('https://apibox.io.vn/v1/barcode?text=ABC-12345&height=80', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const blob = await res.blob();import requests
res = requests.get(
"https://apibox.io.vn/v1/barcode?text=ABC-12345&height=80",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
open("output", "wb").write(res.content)<?php
$ch = curl_init('https://apibox.io.vn/v1/barcode?text=ABC-12345&height=80');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
file_put_contents('output', $response);Response
binary image/svg+xml (Code 128 barcode)
Use cases
- Print shipping and warehouse labels from your order system
- Generate SKU barcodes for products in an online shop or POS
- Add a scannable invoice or order number to PDF documents
- Tag equipment and inventory with internal asset IDs
FAQ
Which barcode symbology does the API produce?
Code 128 (sets B and C with automatic switching). It is read by virtually every handheld and camera scanner. EAN-13/UPC and 2D formats other than QR are not generated; use /v1/qr for QR codes.
Can I encode Vietnamese or other accented characters?
No. Code 128 only covers printable ASCII (codes 32–126), so the API returns an invalid_text error. Remove diacritics or encode an ID instead.
SVG or PNG – which is better for printing?
SVG is vector and stays sharp at any print size, and it includes the human-readable text. Use PNG when the target (some label printers or e-mail clients) cannot render SVG; pick a module_width of 2–4 for good scan quality.
Related APIs
QR Code Generator
Generate QR codes as PNG or SVG with one GET request: URLs, text, WiFi logins, vCards, e-mail, SMS, phone and geo links. Custom colours, size and ECC.
▭Placeholder Image
Get placeholder images of any size for mockups and tests: /v1/placeholder/600x400.png. SVG with custom text and colours, or a solid-colour PNG.
VQRVietQR Generator
Create VietQR / NAPAS 247 bank transfer QR codes with bank, account, amount and transfer note as PNG, SVG or JSON payload. Decode existing VietQR codes.