Barcode

Generate barcodes from a wide range of different formats.

Endpoint

The API can be called via POST method. The endpoint returns an image in the chosen format.

POST/v1/barcode

curl -X POST https://api.apistax.io/v1/barcode \
    -o 'qr-code.webp' \
    -H 'Authorization: Bearer API_KEY_HERE' \
    -H 'Content-Type: application/json' \
    -d '{ "format": "QR_CODE", "content": "Example QR code content"}'

Parameters

The following parameters can be used as JSON fields in the POST request.

format: String

The format of the barcode to be generated. The available types of barcodes can be found under barcodes.

content: String

The content to be encoded in the barcode.

width: Integer = 1

The minimum width of the generated barcode. Must be between 1 and 2000 pixels.

height: Integer = 1

The minimum height of the generated barcode. Must be between 1 and 2000 pixels.

foregroundColor: String = #000000

The foreground color of the barcode. The default is black.

backgroundColor: String = #FFFFFF

The background color of the barcode. The default is white.

output: String = WEBP

The image type in which the barcode is to be generated. The default is WEBP. Possible types are PNG, JPEG, GIF, TIFF and WEBP.

options: Object

Depending on the format of the barcode, there are various options.

AZTEC

characterSet: String

The character set to be used for encoding. For example, UTF-8, US-ASCII, etc.

errorCorrection: Integer

The error correction level as a percentage. The recommended value is 23%.

layers: Integer = 0

Specifies the required number of layers for the code. A negative number (-1, -2, -3, -4) specifies a compact code. 0 indicates to use the minimum number of layers. A positive number (1, 2, .. 32) specifies a normal code.

CODE_128

compact: Boolean

Specifies whether to use compact mode. This can yield slightly smaller bar codes.

DATA_MATRIX

compact: Boolean

Specifies whether to use compact mode. This can yield slightly smaller codes. This option and forceC40 are mutually exclusive.

forceC40: Boolean

Forces C40 encoding for data-matrix. This option and compact are mutually exclusive.

gs1Format: Boolean

Specifies whether the data should be encoded to the GS1 standard.

characterSet: String

The character set to be used for encoding. For example, UTF-8, US-ASCII, etc.

shape: String

Specifies the matrix shape. Possible values are NONE, SQUARE and RECTANGLE.

PDF_417

compact: Boolean

Specifies whether to use compact mode.

autoEci: Boolean

Specifies whether to automatically insert ECIs when encoding.

errorCorrection: Integer

Specifies what degree of error correction to use. The value must be between 0 and 8, where 8 means maximum error correction and 0 means minimum error correction.

characterSet: String

The character set to be used for encoding. For example, UTF-8, US-ASCII, etc.

compaction: String

Specifies what compaction mode to use. Possible values are AUTO, TEXT, BYTE and NUMERIC.

QR_CODE

compact: Boolean

Specifies whether to use compact mode.

gs1Format: Boolean

Specifies whether the data should be encoded to the GS1 standard.

version: Integer

Specifies the exact version of QR code to be encoded. The value must be between 1 and 40.

characterSet: String

The character set to be used for encoding. For example, UTF-8, US-ASCII, etc.

errorCorrection: String

Specifies what degree of error correction to use. Possible values are L (~7% correction), M (~15% correction), Q (~25% correction) and H (~30% correction).

If most parameters are utilized, an example curl request could look like this:

curl -X POST https://api.apistax.io/v1/barcode \
    -o 'qr-code.webp' \
    -H 'Authorization: Bearer API_KEY_HERE' \
    -H 'Content-Type: application/json' \
    -d '{
          "format": "QR_CODE",
          "content": "Example QR code content",
          "width": 200,
          "height": 200,
          "foregroundColor": "#A3A3A3",
          "backgroundColor": "#FFFFFF",
          "output": "PNG",
          "options": {
            "compact": false,
            "gs1Format": false,
            "version": 40,
            "characterSet": "UTF-8",
            "errorCorrection": "Q"
          }
        }'

Barcodes

All supported barcode formats that can be specified using the format parameter.

AZTEC

Aztec codes are 2D barcodes that can encode a large amount of data, including text, URLs, and contact information. They are often used in transportation tickets and mobile marketing.

Aztec example barcode

CODABAR

Codabar is a linear barcode that is often used in libraries, blood banks, and for airbill labels. It is simple and can encode a limited set of characters.

Codabar example barcode

CODE_39

Code 39 is a linear barcode that can encode alphanumeric data. It is widely used in various industries due to its simplicity and readability.

Code 39 example barcode

CODE_93

Code 93 is an improved version of Code 39, offering higher density and better reliability. It is used in logistics and inventory management.

Code 93 example barcode

CODE_128

Code 128 is a high-density linear barcode that can encode all 128 ASCII characters. It is commonly used in shipping and packaging industries.

Code 128 example barcode

DATA_MATRIX

Data Matrix is a 2D barcode that can encode large amounts of data in a small space. It is often used for marking small items and electronic components.

Data Matrix example barcode

EAN_8

EAN-8 is a shortened version of EAN-13, used for small packages where a full EAN-13 barcode would be too large. It is commonly found on small retail items.

EAN 8 example barcode

EAN_13

EAN-13 is a linear barcode used worldwide for marking retail goods. It encodes 13 digits, including a country code and product code.

EAN 13 example barcode

INTERLEAVED_TWO_OF_FIVE

This barcode is used primarily in the industrial and warehousing sectors. It encodes pairs of digits and is efficient for numeric data.

Interleaved Two of Five example barcode

PDF_417

PDF417 is a stacked linear barcode that can store large amounts of data. It is often used in transportation, identification cards, and inventory management.

PDF 417 example barcode

QR_CODE

QR Code is a 2D barcode that can store various types of data, such as URLs, contact information, and text. It is widely used in marketing and mobile applications.

QR Code example barcode

UPC_A

UPC-A is a linear barcode used for tracking trade items in stores. It encodes 12 numerical digits that are unique to each product.

UPC A example barcode

UPC_E

UPC-E is a shortened version of UPC-A, used on small packages where space is limited. It encodes 6 digits but represents a full 12-digit UPC-A code.

UPC E example barcode

Possible errors

Identifier Description
message.contentMustNotBeBlank Parameter content is required and must not be blank.
message.formatMustNotBeNull Parameter format is required.
message.foregroundColorMustBeValid Parameter foregroundColor must be a valid hex color string.
message.backgroundColorMustBeValid Parameter backgroundColor must be a valid hex color string.
message.widthMustBeWithinRange Parameter width must be within 1 and 2000 pixel.
message.heightMustBeWithinRange Parameter height must be within 1 and 2000 pixel.
message.versionMustBeWithinRange Parameter version must be within 1 and 40. Only if format is QR_CODE.
message.charsetDoesNotExist The provided charset could not be found.
message.charsetNotSupported The provided charset is not supported.
message.errorCorrectionMustBeWithinRange Parameter errorCorrection must be within the specified range.
message.layersMustBeWithinRange Parameter layers must be within -4 and 32. Only if format is AZTEC.
message.dataToLargeForSpecifiedLayer Parameter content is to large for specified layers. Only if format is AZTEC.
message.dataToLargeForSpecifiedShape Parameter content is to large for specified shape. Only if format is DATA_MATRIX.
message.dataToLargeForSpecifiedVersion Parameter content is to large for specified version. Only if format is QR_CODE.
message.numericCompactionOnlyAllowedNumericContent Parameter content may contain only numbers if compaction is NUMERIC. Only if format is PDF_417.
message.contentUsesNotSupportedChars Parameter content contains unsupported characters.
message.contentDoesNotMatchRequestedLength Parameter content contains too many or too few characters.
message.contentContainsWrongChecksum Parameter content contains wrong checksum.

It should be noted that there are a number of common error messages, which can be found in the "Possible errors" section of the general documentation.

Barcode costs
Generate barcodes from a wide range of different formats.
1
Credits spent
Credit cost per REST call
0,0040
EUR per call
Price depends on your subscription