Make a Code 128 barcode
curl https://aisenseapi.com/services/v1/barcode/code128/Hello%202026
{"barcode_image":"iVBORw0KGgoAAAANSUhEUgAAAc4AAABQCAAAAAA...","image_type":"png","type":"code128","data":"Hello 2026","modules":134,"width":462,"height":80}The PNG is in barcode_image as base64, ready for an img tag with a data URL or for a file. Spaces and other characters in the data are percent-encoded in the path; Hello%202026 is the text Hello 2026.
The same request as JSON, and as SVG:
curl -X POST https://aisenseapi.com/services/v1/barcode \
-H "Content-Type: application/json" \
-d '{"type": "ean13", "data": "400638133393", "format": "svg"}'
{"barcode_svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"345\" height=\"80\" ...>","image_type":"svg","type":"ean13","data":"4006381333931","modules":95,"width":345,"height":80}Try it
Make a barcode here. Your browser posts the data in a JSON field named data to the type you choose, as the quick start does, and draws the PNG that comes back. Leave secrets and personal data out.
Code 128 for text
Code 128 takes 1 to 80 characters of printable ASCII, the characters from space to tilde: letters, digits, punctuation and the space itself. Letters outside ASCII, such as æ ø å, are refused with HTTP 400 rather than silently changed; a label that must carry them needs a QR code.
The encoder works in code set B and switches to code set C for runs of four or more digits, where two digits share one symbol, so a numeric part of the data takes half the width. The checksum symbol and the stop pattern are added for you; a scanner reads back exactly the text you sent.
EAN-13 for article numbers
EAN-13 takes 12 digits and adds the check digit, or 13 digits whose last one must be the right check digit; a wrong one is refused with the digit it should have been. The answer's data is always the full 13 digits, so 400638133393 comes back as 4006381333931.
The code is the standard 95 modules: the three guards and twelve digits, with the first digit encoded in the parity pattern of the left half, the way every EAN-13 on a shelf is made. Only the bars are drawn; the digits are not printed under them, so the image is the machine-readable part and your label template adds the human-readable line where it belongs.
PNG or SVG, and the size of the image
Each module is three pixels wide and the bars are 80 pixels tall, with a quiet zone of ten modules on either side, so a 95-module EAN-13 is 345 by 80 pixels and a Code 128 grows with its symbols. modules, width and height in the answer give the numbers for the image you got.
Add /svg to the path, or "format": "svg" to the body, for the same code as SVG text in barcode_svg: one rectangle per run of bars on a white background, with shape-rendering set to crisp edges, so it scales to any print size without blur. PNG is 8-bit grayscale, black on white, a few hundred bytes.
Read a barcode back
The way back is /qrcode_decode, which reads barcodes as well as QR codes. Post the PNG from this endpoint, or a clear image of a printed code, and the text comes back in qrcode_content: an EAN-13 with its check digit, a Code 128 as the text it carries. It reads PNG, JPEG, GIF and WebP, so send the PNG rather than the SVG.
What the free barcode API endpoint returns
| Field | Type | Description |
|---|---|---|
| barcode_image | string | The PNG as base64. Present when the format is png. |
| barcode_svg | string | The SVG document as text. Present when the format is svg. |
| image_type | string | png or svg. |
| type | string | code128 or ean13. |
| data | string | What was encoded: the text as sent, or the 13 digits with the check digit. |
| modules | integer | The width of the code in modules, quiet zones not counted. |
| width, height | integer | The image size in pixels, quiet zones counted. |
HTTP 400 when the data does not fit the code
curl https://aisenseapi.com/services/v1/barcode/ean13/5901234123450
{"error":"The check digit of 5901234123450 is wrong; for these twelve digits it is 7.","fix":"type code128 takes 1 to 80 printable ASCII characters; type ean13 takes 12 digits, or 13 with the right check digit; format is png or svg."}Every refusal is HTTP 400 with error and fix: an unknown type, empty data, more than 80 characters or a character outside printable ASCII for Code 128, the wrong number of digits or a wrong check digit for EAN-13, or a format other than png and svg.
Where a barcode from a URL earns its keep
Labels and tickets
An order number or a ticket code as a Code 128 on a PDF or a web page, made at render time from one URL.
Inventory and shelves
EAN-13 for article numbers, with the check digit computed so a typo is caught before it is printed.
Agent-made documents
An agent that assembles a packing slip or a badge gets the image inline and never touches an image library.
Print at any size
The SVG form scales from a sticker to a poster with crisp bars, since it is geometry, not pixels.
Privacy and limits
The data travels in the path or the body and is not stored; the image is computed and answered in the same call, and nothing stays behind. A barcode is readable by anyone who scans it, so put only what a label may show into one.
The service-wide limit is 5000 requests per IP per day, with no key and no account behind it. Every endpoint on the service is listed in the free public REST APIs reference.