Supported Barcode Types¶
GET /v1/barcode/types returns metadata describing every symbology the API can generate.
Base URL: https://barcode.toolkitapi.io
Why this endpoint exists¶
The list of supported types is already in the docs you are reading. The reason to call this endpoint anyway is that generation is validated per symbology: ean13 needs digits, code39 needs a restricted character set, itf needs an even number of digits. If you build a form that lets users pick a type and enter data, you need those constraints programmatically — both to validate before submitting and to render the right input hints.
Hardcoding the list means your validation silently drifts from the server's the first time a symbology is added or a limit changes.
Response¶
{
"total": 11,
"types": [
{
"name": "code128",
"description": "Code 128 — high-density alphanumeric barcode",
"data_format": "Any ASCII characters",
"max_length": null
},
{
"name": "ean13",
"description": "EAN-13 — European Article Number (retail)",
"data_format": "12 or 13 digits (checksum auto-calculated)",
"max_length": 13
}
]
}
The example above is abridged — the live response carries all 11 entries.
Field semantics¶
| Field | Type | Meaning |
|---|---|---|
name |
string | The identifier to pass as barcode_type |
description |
string | Human-readable label, suitable for a dropdown |
data_format |
string | Prose description of accepted input |
max_length |
integer | null | Hard length ceiling; null means unbounded |
max_length: null does not mean "any length". code128 is null because its ceiling is driven by the image width budget rather than a spec-mandated digit count. All generation endpoints additionally cap data at 256 characters, which is the practical limit you will hit first for the variable-length types.
Full type list¶
These are the 11 symbologies currently exposed:
name |
Family | Data format | max_length |
|---|---|---|---|
code128 |
1D alphanumeric | Any ASCII characters | null |
code39 |
1D alphanumeric | A-Z, 0-9, space, and - . $ / + % |
null |
ean13 |
Retail | 12 or 13 digits (checksum auto-calculated) | 13 |
ean8 |
Retail | 7 or 8 digits (checksum auto-calculated) | 8 |
ean14 |
Logistics | 13 or 14 digits (checksum auto-calculated) | 14 |
upca |
Retail (N. America) | 11 or 12 digits (checksum auto-calculated) | 12 |
isbn13 |
Book | 12 or 13 digits starting with 978/979 | 13 |
isbn10 |
Book (legacy) | 9 or 10 characters, digits plus optional X check |
10 |
issn |
Periodical | 7 or 8 digits | 8 |
pzn |
Pharma (Germany) | 6 or 7 digits | 7 |
itf |
Logistics numeric | Even number of digits | null |
The "N or N-1" pattern¶
Every fixed-length symbology accepts either the full length or one digit short, because the trailing character is a checksum. Pass 12 digits to ean13 and the server computes the 13th; pass 13 and it is validated (or treated as supplied).
So max_length: 13 means "at most 13", and data_format tells you 12 is also valid. Validation logic that insists on exactly max_length digits will reject valid input.
itf needs even-length data¶
Interleaved 2 of 5 encodes digit pairs, so an odd number of digits cannot be represented. It is the one type where a plain len(data) <= max_length check is insufficient — you also need len(data) % 2 == 0.
code39 has a restricted alphabet¶
No lowercase letters, no arbitrary punctuation. Allowed: A-Z, 0-9, space, and - . $ / + %. If you let users type freely and select code39, most of their input will fail.
Examples¶
curl¶
curl "https://barcode.toolkitapi.io/v1/barcode/types" \
-H "X-API-Key: $TOOLKIT_API_KEY"
Python¶
import os
import httpx
API = "https://barcode.toolkitapi.io"
headers = {"X-API-Key": os.environ["TOOLKIT_API_KEY"]}
with httpx.Client(base_url=API, headers=headers) as client:
resp = client.get("/v1/barcode/types")
resp.raise_for_status()
data = resp.json()
for t in data["types"]:
limit = t["max_length"] if t["max_length"] is not None else "unbounded"
print(f"{t['name']:<10} max={limit:<10} {t['description']}")
JavaScript¶
const API = "https://barcode.toolkitapi.io";
async function fetchTypes() {
const resp = await fetch(`${API}/v1/barcode/types`, {
headers: { "X-API-Key": process.env.TOOLKIT_API_KEY },
});
if (!resp.ok) throw new Error(`Failed: ${resp.status}`);
return (await resp.json()).types;
}
const types = await fetchTypes();
// Build a dropdown
const options = types.map((t) => ({ label: t.description, value: t.name }));
// Derive a maxlength hint for an input field
const hints = Object.fromEntries(types.map((t) => [t.name, t.max_length]));
Driving validation from the metadata¶
A pattern that keeps your client in sync with the server without redeploying:
import re
def validate_for_type(data: str, type_info: dict) -> str | None:
"""Return an error message, or None if the input looks valid."""
name = type_info["name"]
max_len = type_info["max_length"]
if max_len is not None and len(data) > max_len:
return f"{name} accepts at most {max_len} characters"
if name == "itf":
if not data.isdigit():
return "itf requires digits only"
if len(data) % 2 != 0:
return "itf requires an even number of digits"
if name == "code39":
if not re.fullmatch(r"[A-Z0-9 \-.$/+%]+", data):
return "code39 allows A-Z, 0-9, space and - . $ / + %"
if name in {"ean13", "ean8", "ean14", "upca", "issn", "pzn"} and not data.isdigit():
return f"{name} requires digits only"
return None
Cache the /v1/barcode/types response — it changes only when the product does. A process-lifetime cache or a few-hours TTL is plenty, and it avoids adding a network hop to every keystroke in a form.
Related¶
- Generating Barcodes — the GET raw-image and POST JSON generation routes
- Bulk Generation — up to 20 barcodes per request
- Decoding Barcodes — read barcodes back out of an image