Barcode generator API: one POST, SVG output, six formats
Your warehouse app prints shipping labels. Each label needs a Code128 barcode for the tracking number. You could install a barcode library, render to canvas, export as PNG, and embed it in your label template. Or you could send one POST and get back an SVG.
The botoi /v1/barcode endpoint encodes data into six barcode formats and returns
an SVG string inside a JSON response. No npm package. No build step. No canvas dependency.
The API call
Send a POST request with the data and format:
curl -X POST https://api.botoi.com/v1/barcode \
-H "Content-Type: application/json" \
-d '{
"data": "5901234123457",
"format": "ean-13"
}' The response wraps the SVG in a standard JSON envelope:
{
"success": true,
"data": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"200\" ...>...</svg>",
"data": "5901234123457",
"encoding": "ean-13"
}
}
Extract the svg field, drop it into an <img> tag, inline it
in HTML, or pipe it to a file. The SVG renders sharp at any size because it's vector-based;
no rasterization artifacts at 300 DPI or higher.
Parameters
The endpoint accepts five parameters. Only data is required:
- data (string, required): The value to encode. For EAN-13, pass 13 digits. For Code128, pass any printable ASCII string.
- format (string, default
code128): One ofcode128,ean-13,ean-8,upc-a,itf-14, ormsi. - width (number, default 200): Image width in pixels. Range: 50 to 2000.
- height (number, default 80): Image height in pixels. Range: 20 to 1000.
- show_text (boolean, default
true): Whether to render the encoded value as text below the bars.
Here's a Code128 barcode with all parameters set:
curl -X POST https://api.botoi.com/v1/barcode \
-H "Content-Type: application/json" \
-d '{
"data": "SHIP-2026-03-29-0042",
"format": "code128",
"width": 300,
"height": 100,
"show_text": true
}' Practical examples
Shipping label generation
Encode a tracking number as Code128 for packing slips and shipping labels. Code128 handles mixed alphanumeric strings, so tracking numbers like "1Z999AA10123456784" work without preprocessing.
curl -X POST https://api.botoi.com/v1/barcode \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"data": "1Z999AA10123456784",
"format": "code128",
"width": 400,
"height": 80,
"show_text": true
}' Inventory management system
Print Code128 labels for warehouse bins and shelves. Staff scan them with handheld readers during pick-and-pack. The barcode encodes the full location path: warehouse, shelf, bin.
curl -X POST https://api.botoi.com/v1/barcode \
-H "Content-Type: application/json" \
-d '{
"data": "SKU-WH3-SHELF-09-BIN-44",
"format": "code128",
"width": 250,
"height": 60,
"show_text": true
}' Retail product labels (EAN-13)
EAN-13 is the international standard for retail products. Pass the 13-digit GTIN and the API returns an SVG sized for standard shelf-edge labels.
curl -X POST https://api.botoi.com/v1/barcode \
-H "Content-Type: application/json" \
-d '{
"data": "5901234123457",
"format": "ean-13",
"width": 200,
"height": 100,
"show_text": true
}' Node.js batch generation for a product catalog
Generate barcodes for an entire product catalog in parallel. This script fires four requests concurrently and collects the SVG strings:
const products = [
{ sku: "4006381333931", name: "wireless-earbuds" },
{ sku: "5901234123457", name: "usb-c-hub" },
{ sku: "8710398527837", name: "mechanical-keyboard" },
{ sku: "3614272049529", name: "webcam-1080p" },
];
async function generateBarcodes() {
const results = await Promise.all(
products.map(async (product) => {
const res = await fetch("https://api.botoi.com/v1/barcode", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY",
},
body: JSON.stringify({
data: product.sku,
format: "ean-13",
width: 200,
height: 100,
show_text: true,
}),
});
const json = await res.json();
return { name: product.name, svg: json.data.svg };
})
);
console.log(`Generated ${results.length} barcodes`);
return results;
}
generateBarcodes(); Output:
Generated 4 barcodes For catalogs with hundreds of products, batch in groups of 20-50 to stay within rate limits. The free tier caps at 5 requests per minute; an API key removes that limit.
Node.js example: barcode labels for order fulfillment
This Express server exposes a /labels/:orderId endpoint. When your fulfillment
system or label printer fetches this URL, it gets back an SVG barcode encoding the order's
tracking number.
import express from "express";
import fs from "fs/promises";
const app = express();
app.use(express.json());
app.get("/labels/:orderId", async (req, res) => {
const trackingNumber = `SHIP-${req.params.orderId}`;
const barcodeRes = await fetch("https://api.botoi.com/v1/barcode", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY",
},
body: JSON.stringify({
data: trackingNumber,
format: "code128",
width: 400,
height: 80,
show_text: true,
}),
});
const json = await barcodeRes.json();
res.setHeader("Content-Type", "image/svg+xml");
res.setHeader("Cache-Control", "public, max-age=86400");
res.send(json.data.svg);
});
app.listen(3000, () => console.log("Label server running on port 3000")); Usage:
# Returns an SVG barcode for order ORD-7291
curl http://localhost:3000/labels/ORD-7291 --output label.svg The 24-hour cache header prevents duplicate API calls for the same order. In production, add a CDN or Redis cache in front of this route.
When to use which format
Format | Characters | Length | Use case
-----------|---------------------|-----------|-------------------------------------------
Code128 | ASCII 32-126 | Variable | Shipping labels, internal IDs, serial numbers
EAN-13 | Digits only | 13 | Retail products (international standard)
EAN-8 | Digits only | 8 | Small retail packages
UPC-A | Digits only | 12 | Retail products (US and Canada)
ITF-14 | Digits only | 14 | Shipping cartons and outer packaging
MSI | Digits only | Variable | Warehouse shelves and inventory bins Code128 is the default for a reason: it encodes the widest range of characters and works for most internal systems. Switch to EAN-13 or UPC-A when your product needs a retail-scannable barcode. Use ITF-14 for outer carton labels in logistics. MSI fits warehouse shelf labeling where you need numeric-only codes with a simple check digit.
Key points
- POST /v1/barcode returns an SVG barcode inside a JSON response
- Supported formats: Code128, EAN-13, EAN-8, UPC-A, ITF-14, MSI
- Parameters: data, format, width, height, show_text
- Code128 handles letters, digits, and symbols; the rest are numeric only
- SVG output scales cleanly for both screen display and 300 DPI print
- Free tier: 5 requests per minute, no API key required
The free tier at 5 requests per minute covers development, testing, and low-volume label
printing. For batch generation or high-traffic fulfillment systems, pass your API key in the
Authorization: Bearer header. Check the
API docs
for the full endpoint reference.
Frequently asked questions
- Do I need an API key to generate barcodes?
- No. The free tier allows anonymous access at 5 requests per minute with IP-based rate limiting. For production workloads, add an API key in the Authorization header to raise the limit.
- Can I get a PNG instead of SVG?
- The API returns SVG inside a JSON response. SVG scales to any resolution without pixelation, which makes it ideal for thermal label printers at 203 or 300 DPI. To convert to PNG, rasterize the SVG with sharp, Inkscape, or a browser canvas element.
- What characters can I encode in Code128?
- Code128B supports printable ASCII characters from space (0x20) through tilde (0x7E). This covers uppercase and lowercase letters, digits, punctuation, and common symbols. For numeric-only data like GTINs, use EAN-13, EAN-8, or UPC-A.
- How do I embed the SVG barcode in a PDF?
- Extract the svg field from the JSON response and pass it to your PDF library. Libraries like Puppeteer, wkhtmltopdf, and WeasyPrint render inline SVG natively. For reportlab or jsPDF, convert the SVG to PNG first with sharp or canvas.
- What is the maximum data length?
- Code128 can encode strings up to about 80 characters before the barcode becomes too wide for standard label printers. EAN-13 is fixed at 13 digits, EAN-8 at 8, UPC-A at 12, and ITF-14 at 14. Keep data short for reliable scanning.
Try this API
Barcode Generator API — interactive playground and code examples
More tutorial posts
Start building with botoi
150+ API endpoints for lookup, text processing, image generation, and developer utilities. Free tier, no credit card.