Barcodes

5 endpoints for barcode generation, decoding, bulk workflows, and type discovery.

Method Endpoint Purpose
POST /v1/barcode/generate Generate barcode output as base64 PNG or SVG markup
GET /v1/barcode/generate Stream raw barcode image bytes (PNG or SVG)
POST /v1/barcode/decode Decode barcodes and QR codes from an image
POST /v1/barcode/bulk Generate up to 20 barcodes in one request
GET /v1/barcode/types Return supported barcode types and constraints

Python SDK Examples

Generate EAN-13 barcode

from toolkitapi import Barcode

bc = Barcode(api_key="tk_...")

result = bc.generate(
    data="5901234123457",
    barcode_type="ean13",
    format="png",
    include_text=True,
)

print(result["barcode_type"])  # ean13
png_b64 = result["image"]

Generate Code128 as SVG

from toolkitapi import Barcode

bc = Barcode(api_key="tk_...")

result = bc.generate(
    data="ORDER-2026-00091",
    barcode_type="code128",
    format="svg",
    include_text=False,
    fg_color="#111827",
    bg_color="#ffffff",
)

print(result["svg"][:120])

Stream raw barcode bytes and save file

Use the GET variant through generate_image.

from toolkitapi import Barcode

bc = Barcode(api_key="tk_...")

raw = bc.generate_image(
    data="9783161484100",
    barcode_type="isbn13",
    format="png",
    module_height=22.0,
    quiet_zone=8.0,
    output_path="book-isbn.png",
)

print(len(raw))

Decode barcodes from a remote image

from toolkitapi import Barcode

bc = Barcode(api_key="tk_...")

decoded = bc.decode(url="https://toolkitapi.io/images/shipping-label.png")
print(decoded["found"])
for item in decoded["results"]:
    print(item["type"], item["data"])

Bulk-generate shipping barcodes

from toolkitapi import Barcode

bc = Barcode(api_key="tk_...")

result = bc.bulk(
    items=[
        {"data": "PKG-10001", "barcode_type": "code128", "include_text": True},
        {"data": "PKG-10002", "barcode_type": "code128", "include_text": True},
        {"data": "PKG-10003", "barcode_type": "code128", "include_text": True},
    ]
)

print(result["total"])  # 3

List supported barcode types

from toolkitapi import Barcode

bc = Barcode(api_key="tk_...")

types = bc.types()
for t in types["types"]:
    print(t["name"], t["data_format"], t["max_length"])

Request Parameters – POST /v1/barcode/generate

Parameter Type Description
data string Value to encode, up to 256 characters
barcode_type string One of code128, code39, ean13, ean8, ean14, upca, isbn13, isbn10, issn, pzn, itf
format string png or svg
include_text boolean Include human-readable text under bars
fg_color string Foreground hex color
bg_color string Background hex color
module_height float Bar height in mm, 5.0 to 50.0
quiet_zone float Quiet zone width in mm, 0.0 to 20.0

Request Parameters – POST /v1/barcode/decode

Parameter Type Description
image string Base64 image containing symbols
url string Public URL to image containing symbols

Exactly one of image or url is required.

Request Parameters – POST /v1/barcode/bulk

Parameter Type Description
items array 1 to 20 barcode specs
format string png only

Response Fields – Generate

Field Type Description
image string Base64 PNG when format is png
svg string SVG markup when format is svg
format string Output format used
barcode_type string Symbology used
data string Encoded data
include_text boolean Whether text labels were included

Response Fields – Types

Field Type Description
total integer Number of supported symbologies
types array Type metadata with name, description, data_format, max_length

Tip

Use GET /v1/barcode/types before building validation on the client side. It provides both format rules and max length hints for each barcode type.