Barcode Reader API
Read every 1D / 2D barcode in a PNG or JPEG: EAN-13 / 8, UPC, Code 128 / 39 / 93, ITF, QR, DataMatrix, PDF417, Aztec, with position and GS1 country.
Upload a photo or a scan and get all the barcodes found in it, with their format, decoded text, corner positions and orientation. Linear codes: EAN-13, EAN-8, UPC-A, UPC-E, ISBN, Code 128 (shipping labels), Code 39, Code 93, Codabar, ITF / ITF-14 and GS1 DataBar. Matrix codes: QR, Micro QR, rMQR, DataMatrix (medicines, electronic parts), PDF417 (tickets, ID documents), Aztec and MaxiCode. Rotated, mirrored and inverted (light on dark) codes are tried automatically; formats=ean13,code128 limits the search (faster, fewer false hits) and max caps the number of codes.
Retail codes come with the GTIN-14 and the GS1 prefix country (893 = Vietnam), the same table as /v1/gtin-check. QR codes are classified (URL, Wi-Fi, vCard…) and VietQR payment codes are decoded into bank, account and amount. Binary payloads are returned in base64.
Decoding uses zxing-cpp compiled to WebAssembly (zxing-wasm, MIT / Apache-2.0), running inside our servers: images are not sent to any third party nor stored. Images over 2400 px are scaled down first; limit 30 megapixels within the file size of your plan. Sharp, well-lit photos where the code is at least ~2 px per bar read best.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
file | body | file | yes | PNG or JPEG image (multipart, raw body or file_base64). | |
formats | query|body | string | no | Comma-separated formats to look for: ean13, ean8, upca, upce, code128, code39, code93, codabar, itf, databar, qr, microqr, datamatrix, pdf417, aztec, maxicode, or linear, matrix, retail. Default: all. | |
max | query|body | number | no | 20 | Maximum number of codes returned (1–50). |
fast | query|body | boolean | no | false | Skip the slower "try harder" pass (good for clean, computer-generated images). |
Example
curl -X POST "https://apibox.io.vn/v1/barcode-read" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "0=@./my-file"const form = new FormData();
form.append('0', fileInput.files[0]);
const res = await fetch('https://apibox.io.vn/v1/barcode-read', {
method: 'POST',
headers: { Authorization: 'Bearer YOUR_API_KEY' },
body: form,
});
console.log(await res.json());import requests
res = requests.post(
"https://apibox.io.vn/v1/barcode-read",
headers={"Authorization": "Bearer YOUR_API_KEY"},
files={"0": open("my-file", "rb")},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/barcode-read');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
CURLOPT_POSTFIELDS => ['0' => new CURLFile('my-file')],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"found": true,
"count": 1,
"barcodes": [
{
"format": "EAN13",
"symbology": "EANUPC",
"text": "8934588012228",
"content_type": "Text",
"position": {
"top_left": {
"x": 33,
"y": 0
},
"top_right": {
"x": 317,
"y": 0
},
"bottom_right": {
"x": 317,
"y": 149
},
"bottom_left": {
"x": 33,
"y": 149
}
},
"orientation": 0,
"is_mirrored": false,
"is_inverted": false,
"gtin": {
"gtin14": "08934588012228",
"gs1_prefix": {
"prefix": "893",
"name": "GS1 Vietnam",
"country_code": "VN"
}
}
}
],
"image": {
"format": "png",
"width": 339,
"height": 165
},
"decoder": "zxing-cpp (zxing-wasm)"
}
Use cases
- Read product barcodes from photos in inventory or price-check apps
- Match shipping labels (Code 128) from parcel photos
- Read DataMatrix codes on medicine boxes
- Scan PDF417 / QR on tickets and documents uploaded by users
FAQ
Can it read several codes in one image?
Yes, up to 50 (20 by default), each with its corners in pixels of the original image.
Why is a UPC-A code returned as EAN-13?
A UPC-A code is an EAN-13 starting with 0; the reader reports the 13-digit form, which is also the valid GTIN.
Which image formats are accepted?
PNG and JPEG. Convert HEIC / WebP first (for example with /v1/image-resize).
Related APIs
QR Code Generator
Generate QR codes as PNG or SVG with one GET request: URLs, text, WiFi logins, vCards, e-mail, SMS, phone and geo links. Custom colours, size and ECC.
|||Barcode Generator
Create Code 128 barcodes for labels, SKUs and shipping with a single request. SVG with human-readable text or PNG, custom height, width and colours.
▭Placeholder Image
Get placeholder images of any size for mockups and tests: /v1/placeholder/600x400.png. SVG with custom text and colours, or a solid-colour PNG.