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
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| barcode | String | Yes | For validate, pass the full barcode (including its check digit). For generate and check_digit, pass only the barcode body, without the check digit. |
| mode | String | No | validate (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
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| valid | Boolean | No | Whether the barcode is valid. |
| format | String | No | The barcode format. |
| length | Integer | No | The barcode length. |
| barcode | String | No | The barcode value. |
| check_digit | Integer | No | The check digit. |
| expected_check_digit | Integer | No | The expected check digit. |
Example:
{
"valid": true,
"format": "EAN-13",
"length": 13,
"barcode": "4006381333931",
"check_digit": 1,
"expected_check_digit": 1
}generate
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| mode | String | No | Echoes the mode used, "generate". |
| format | String | No | The barcode format. |
| body | String | No | The barcode body you sent (without check digit). |
| check_digit | Integer | No | The computed check digit. |
| barcode | String | No | The full barcode, with the computed check digit appended. |
Example:
{
"mode": "generate",
"format": "EAN-13",
"body": "400638133393",
"check_digit": 1,
"barcode": "4006381333931"
}check_digit
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| mode | String | No | Echoes the mode used, "check_digit". |
| format | String | No | The barcode format. |
| body | String | No | The barcode body you sent (without check digit). |
| check_digit | Integer | No | The 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.