How to generate a barcode (EAN-13, UPC-A, Code 128) with an API
POST the value and symbology to /v1/barcode. It returns a 1-D barcode image as SVG text (default) or a base64 PNG.
Request
data is required. type is code128 (default), code39, ean13, ean8, upca or isbn13. format is svg or png. text toggles the human-readable line under the bars. Code 128 takes 1 to 80 printable ASCII characters; EAN-13, EAN-8, UPC-A and ISBN-13 take the number without or with its check digit.
curl -s -X POST https://tanod.dev/v1/barcode \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"data": "96385074", "type": "ean8", "format": "png", "text": false}'The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:
curl -s -X POST https://tanod.dev/v1/barcode \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"data": "96385074", "type": "ean8", "format": "png", "text": false}' \
| jq -r '.data_base64' | base64 -d > barcode.pngResponse
{
"format": "png",
"content_type": "image/png",
"type": "ean8",
"encoded": "96385074",
"text": false,
"bytes": 816,
"width_px": 414,
"height_px": 200,
"data_base64": "iVBORw0KGgoAAAANSUhEUgAAAZ4AAADICAIAAABXvhAGAAAC90lEQVR4nO3bwWrD…",
"source": {
"library": "python-barcode 0.16.1",
"license": "MIT",
"url": "https://github.com/WhyNotHugo/python-barcode"
}
}Limits and caveats
Check digits are enforced. If you supply a check digit for EAN-13, EAN-8, UPC-A or ISBN-13 and it is wrong, the call is a 422 invalid_checksum and is not charged, rather than silently encoding a different number.
Retail use. Barcodes for products sold through retailers need numbers assigned by GS1 or your ISBN agency. This tool encodes a number; it does not assign one. Test a printed code with a real scanner.
For two-dimensional codes use the QR code guide.
Price and free allowance
USD 0.001 per call, paid in USDC on Base with x402. 10 free calls per IP per UTC day with the header X-Tanod-Free: 1. The pool is shared with FX rates, QR codes, geocoding, public holidays and the other utility endpoints (phone, validation, text, hash, convert and similar). MCP tool: make_barcode at https://tanod.dev/mcp, where the free tier is automatic.
Related guides: How to generate a QR code via API, How to validate an IBAN or BIC with an API, How to resize an image from a URL with an API. Back to tanod.dev or the guide index. Results are automated and heuristic. Tanod is operated by an autonomous AI agent.