apyhub
Back

Generate Code 128 Barcode as SVG API

What it does

Code 128 Barcode Generator turns a text string into a valid Code 128 barcode. Send plain ASCII text in the text field, and you can also set format to json or svg and adjust height between 10 and 400.

Use it when you need a barcode for product labels, inventory flows, shipping workflows, or any system that has to encode short alphanumeric identifiers. The input is constrained to printable ASCII and a maximum length of 80 characters, which makes the output predictable for downstream printing and scanning.

The default response is JSON containing the SVG markup, a data URL for use in an img tag, and the image size. Set format to svg to get the raw SVG file instead. That makes it a good fit for backend jobs, document generation pipelines, and internal tools that need a standards-based barcode from a simple string.

If you are rendering labels, receipts, or packaging assets, this gives you a clean way to create Code 128 output without building barcode logic yourself.

POST
Generate a Code 128 barcode as valid SVG
https://api.eu.apyhub.com/freedailypro/generate-code-128-barcode-as-svg-api

QUICKSTART

GUIDE

Quickstart

Generate a Code 128 barcode from plain text using the required text field. Add format and height if you need them.

curl -X POST "https://api.eu.apyhub.com/freedailypro/generate-code-128-barcode-as-svg-api" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text":"Hello123"}'

What you'll get back

By default, a JSON object with the barcode as SVG markup and as a data URL:

{
  "tool": "...",
  "result": {
    "svg": "<svg ...>...</svg>",
    "dataUrl": "data:image/svg+xml;...",
    "width": 266,
    "height": 108
  }
}
TRY ITLIVE · 10 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*

About this endpoint

What it does

Generates a Code 128 barcode from the provided text and returns it as a scalable SVG. By default the response is JSON that contains the SVG markup, a data URL and the image size. Set format to svg to get the raw SVG file instead.

Request Body

ParameterTypeMandatoryDescription
textStringYesBarcode content. 1 to 80 characters, printable ASCII only.
formatENUMNoOutput format. Allowed values: json, svg. Default: json.
heightNumberNoHeight of the bars in pixels. Minimum 10, maximum 400. Default: 80.

Response

By default (format omitted or json) the endpoint returns a JSON object. With format set to svg it returns the raw SVG file (image/svg+xml) instead.

ParameterTypeDescription
toolStringName of the tool that generated the barcode.
result.svgStringThe barcode as SVG markup.
result.dataUrlStringThe same barcode as a data URL (data:image/svg+xml), ready to use in an img tag.
result.widthNumberImage width in pixels.
result.heightNumberImage height in pixels. Slightly larger than the requested height, because of the margin around the bars.
▣ 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.