Home / API docs / Barcode API
More

Barcode API

GET /api/barcode $0.01 per call USDC on Base · x402

Barcode generator for product, shipping, and inventory labels: GET ?data=&type= and receive a print-ready SVG plus PNG (base64) and a data: URI. Types: code128 (default), ean13, ean8, upca, upce, code39, itf14, gs1-128, codabar, datamatrix, pdf417, aztec. Check digits, quiet zones, and the human-readable line are handled per spec; invalid input for a symbology returns a clear 400. Deterministic, no network. QR codes live at /api/qr.

Parameters

NameInDescription
dataqueryrequiredValue to encode (required, up to 500 chars; digits-only types validate length + check digit)
typequerySymbology: code128 (default), ean13, ean8, upca, upce, code39, itf14, gs1-128, codabar, datamatrix, pdf417, aztec
scalequeryModule width multiplier for the PNG (1-8, default 3)
heightqueryBar height for 1D types (4-60, default 12)
text_linequerySet to 'false' to omit the human-readable text under the bars
darkqueryHex color of the bars (default #000000)
lightqueryHex background color (default #ffffff)

Example request

curl "https://api.webbersites.com/api/barcode?data=012345678905&type=upca"
# first call returns 402 + payment requirements; an x402 client pays and retries automatically

Example response

{
    "data": "012345678905",
    "type": "upca",
    "svg": "<svg …>",
    "png_base64": "iVBORw0…",
    "data_uri": "data:image/png;base64,…"
}
MCP tool: get_barcode — via npx -y webbersites-x402-mcp (local, key stays on your machine) or the remote endpoint https://api.webbersites.com/mcp.

How payment works

There is no signup and no API key. Call the endpoint; it replies 402 Payment Required with machine-readable payment requirements. Your client signs a USDC transfer authorization (EIP-3009, gasless) and retries with the X-PAYMENT header — @x402/fetch does this automatically. See the overview for a working snippet.