QR Code Decoder API

Free API Service by Coland Studio

What is QR Code Decoder / Bar Code Decoder?

A script to read and decode QR code and bar code, return the decoded text to user.

How does it work?

The API use ZBar bar code reader, currently supports QR code and bar code. Since it requires command line to decode, most shared hosting servers are not able to fulfill the requirements. If your site hosted in shared hosting and you need a function to decode QR codes or bar codes, you can use our API service to achieve.

API Service

To init the API:

<?php
$ch = curl_init("http://www.qr-decoder.com/api/v1/decode");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);

if ((version_compare(PHP_VERSION, '5.5') >= 0)) {
	$postvars = array('qr'=>new CURLFile("/path/to/the/qr/code/image.png"));
} else {
	$postvars = array('qr'=>'@'.realpath("/path/to/the/qr/code/image.png"));
}

curl_setopt($ch, CURLOPT_POST      ,1);
curl_setopt($ch, CURLOPT_POSTFIELDS    ,$postvars);

$json = curl_exec ($ch);

$qr_decoded=json_decode($json, true);
?>
	

Sample returned JSON string

{"result":true,"info":[{"type":"QR-Code","data":"http:\/\/qr-decoder.com"}]}

Get the decoded data

The API will return a JSON string. With the key result value true on success and false on failure.

<?php
if ($qr_decoded["result"]){
    foreach ($qr_decoded["info"] as $qr){
    echo htmlspecialchars($qr["data"])."<br />";
    }
}else{
    echo "Decode error:" .$qr_decoded["reason"];
}
?>
	

The picture may contains more than one QR code and/or bar code, so the decoded data will be returned in array of $qr_decoded["info"]. Therefore a for loop required to go through each decoded data. The value of key data will be the decoded data.

API Demo

Please upload a QR code or bar code image:

Response:

Limitation

Upload image size limited to 4MB maximum, if the image is too large please resize before making API request. Since the decode process consume certain CPU resources, we limited the usage of API to 180 requests per hour per IP address. Continous excess usage / hacking / brute force of API will be permanently blocked.

Support Us!

It's simple, we cannot pay a VM without supports. The software consume CPU power to decode, a VM required to provide stable service. If you use the decoder for commercial purpose, please make a small donation to support us. If you are a developer - most likely the API users, please make it known to your end users.

Make a small Donation by PayPal:
USD

Disclaimer

The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.