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 example barcode

CODABAR

Codabar example barcode

CODE_39

Code 39 example barcode

CODE_93

Code 93 example barcode

CODE_128

Code 128 example barcode

DATA_MATRIX

Data Matrix example barcode

EAN_8

EAN 8 example barcode

EAN_13

EAN 13 example barcode

INTERLEAVED_TWO_OF_FIVE

Interleaved Two of Five example barcode

PDF_417

PDF 417 example barcode

QR_CODE

QR Code example barcode

UPC_A

UPC A example barcode

UPC_E

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