apyhub
Back
DATA VALIDATION · DEVELOPER TOOLS

Validate Or Generate Barcode Check Digits API

What it does

Barcode Check Digit Validator checks or generates barcode check digits for EAN, UPC, and ISBN values. Send a barcode string, and use mode to validate a full code, generate a check digit for the body, or calculate the check digit directly.

The response tells you whether the barcode is valid and may include the detected format, length, the normalized barcode, and check-digit fields such as check_digit and expected_check_digit. That makes it useful when you need to catch mistyped product codes, verify imported catalog data, or finish building a barcode before storing or printing it.

Use it in inventory systems, product feeds, checkout flows, or admin tools where barcode accuracy matters. It gives you a small, focused validation step without having to implement barcode math in your own service.

If you already have a full code, validate it. If you only have the body, generate the check digit and compare the result before moving the record downstream.

POST
Validate or generate barcode check digits (EAN/UPC/ISBN).
https://api.eu.apyhub.com/creightonnick0/validate-barcode-check-digits

QUICKSTART

GUIDE

Quickstart

Validate a barcode check digit by sending the full barcode you want to check.

curl -X POST "https://api.eu.apyhub.com/creightonnick0/validate-barcode-check-digits" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"barcode":"4006381333931"}'

What you'll get back

{
  "valid": true,
  "format": "EAN-13",
  "length": 13,
  "barcode": "4006381333931",
  "check_digit": 1,
  "expected_check_digit": 1
}

Generate a check digit (and the finished barcode)

Send the barcode body without its check digit, and set mode to generate:

curl -X POST "https://api.eu.apyhub.com/creightonnick0/validate-barcode-check-digits" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"barcode":"400638133393","mode":"generate"}'
{
  "mode": "generate",
  "format": "EAN-13",
  "body": "400638133393",
  "check_digit": 1,
  "barcode": "4006381333931"
}

Get just the check digit

Same body, with mode set to check_digit — this skips assembling the full barcode and returns only the computed digit:

curl -X POST "https://api.eu.apyhub.com/creightonnick0/validate-barcode-check-digits" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"barcode":"400638133393","mode":"check_digit"}'
{
  "mode": "check_digit",
  "format": "EAN-13",
  "body": "400638133393",
  "check_digit": 1
}
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*
The barcode (full, for validate; body without check digit, for generate)
Operation to perform on the barcode.

About this endpoint

What it does

Validates a barcode's check digit, or computes the check digit for a barcode body, for an EAN/UPC/ISBN barcode. The request body accepts the barcode and an optional mode, and the response shape depends on which mode you use — see the tables below.

Request Body

ParameterTypeMandatoryDescription
barcodeStringYesFor validate, pass the full barcode (including its check digit). For generate and check_digit, pass only the barcode body, without the check digit.
modeStringNovalidate (default) checks whether a full barcode's check digit is correct. generate computes the check digit for a barcode body and returns the full assembled barcode. check_digit computes the check digit for a barcode body only, without assembling the full barcode.

Response

The response fields differ by mode:

validate

ParameterTypeMandatoryDescription
validBooleanNoWhether the barcode is valid.
formatStringNoThe barcode format.
lengthIntegerNoThe barcode length.
barcodeStringNoThe barcode value.
check_digitIntegerNoThe check digit.
expected_check_digitIntegerNoThe expected check digit.

Example:

{
  "valid": true,
  "format": "EAN-13",
  "length": 13,
  "barcode": "4006381333931",
  "check_digit": 1,
  "expected_check_digit": 1
}

generate

ParameterTypeMandatoryDescription
modeStringNoEchoes the mode used, "generate".
formatStringNoThe barcode format.
bodyStringNoThe barcode body you sent (without check digit).
check_digitIntegerNoThe computed check digit.
barcodeStringNoThe full barcode, with the computed check digit appended.

Example:

{
  "mode": "generate",
  "format": "EAN-13",
  "body": "400638133393",
  "check_digit": 1,
  "barcode": "4006381333931"
}

check_digit

ParameterTypeMandatoryDescription
modeStringNoEchoes the mode used, "check_digit".
formatStringNoThe barcode format.
bodyStringNoThe barcode body you sent (without check digit).
check_digitIntegerNoThe computed check digit.

Example:

{
  "mode": "check_digit",
  "format": "EAN-13",
  "body": "400638133393",
  "check_digit": 1
}

Note: check_digit returns everything generate does except the assembled barcode field — that's the field to reach for if you need the finished code, not just the digit.

Body

Name
Type
Description
bodyREQUIRED
object
▣ 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.