apyhub
Back
▣ OUTPUT KIT

Generate Barcode as SVG/PNG API

What it does

Barcode Generator turns a string into a downloadable barcode image. Send data, choose a barcode type, and optionally set format, width, height, margin, bg, and fg to control the output.

It supports code128, code39, ean13, ean8, upca, datamatrix, and pdf417. For ean13, ean8, and upca, the input data must be digits with a valid check digit. The response is binary image data, returned as either png or svg.

Use it when you need barcodes for product labels, order slips, shipping workflows, inventory systems, or generated documents. You can keep the default dimensions for standard labels or adjust the size and quiet zone to fit your print layout.

Barcode Generator is a simple way to generate machine-readable codes from application data without building barcode rendering into your own stack.

POST
Generate Barcode
https://api.eu.apyhub.com/frolic/generate-barcode-svg-png

QUICKSTART

GUIDE

Quickstart

Generate a barcode from the required data value and receive the image bytes in response.

curl -X POST "https://api.eu.apyhub.com/frolic/generate-barcode-svg-png" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "data=FROLIC-12345"

What you'll get back

Returns a binary file stream (string with format: "binary"), not a JSON object.

<binary barcode image>
TRY ITLIVE · 5 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body
Content to encode; ean13, ean8 and upca need digits with a valid check digit
Background colour, hex such as FFFFFF
Foreground colour, hex such as 000000
code128 (default), code39, ean13, ean8, upca, datamatrix or pdf417

About this endpoint

What it does

Generates a barcode from the supplied body fields and returns the rendered barcode as binary content. You can choose the barcode symbology, output format, dimensions, colors, and margin.

Request Body

ParameterTypeMandatoryDescription
dataStringYesContent to encode. ean13, ean8, and upca require digits with a valid check digit.
bgStringNoBackground colour as a hex value such as FFFFFF. Default: FFFFFF.
fgStringNoForeground colour as a hex value such as 000000. Default: 000000.
typeENUMNoBarcode type. Allowed values: code128, code39, ean13, ean8, upca, datamatrix, pdf417. Default: code128.
widthIntegerNoWidth in pixels. Minimum 32, maximum 2000. Default: 400, or 300 for datamatrix.
formatENUMNoOutput format. Allowed values: png, svg. Default: png.
heightIntegerNoHeight in pixels. Minimum 32, maximum 2000. Default: 150, or 300 for datamatrix.
marginIntegerNoQuiet zone around the code. Minimum 0, maximum 50. Default: 10.

Response

Returns the generated barcode as binary data. The output schema is a binary string, so the success response is a file-like payload rather than a JSON object.

Notes

The width and height fields accept values from 32 to 2000. If you choose datamatrix, the defaults change to 300 for both dimensions instead of the standard 400 width and 150 height.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.