How to Implement an EAN Barcode Look Up API in PHP

Cloudmersive
1 min readMar 14, 2023

Scanning 2D EAN barcodes isn’t the only way to find information about a product. You can process the EAN number with a Barcode Look Up API to accomplish the same goal — and thankfully, you can implement one for free using the PHP code examples provided below.

First, run the following command to install the SDK:

composer require cloudmersive/cloudmersive_barcode_api_client

After that, use the below code to structure your API call. Before you do that, you’ll first need to grab a free-tier API key by registering a free account on our website (this allows a limit of 800 API calls per month):

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');



$apiInstance = new Swagger\Client\Api\BarcodeLookupApi(


new GuzzleHttp\Client(),
$config
);
$value = "value_example"; // string | Barcode value

try {
$result = $apiInstance->barcodeLookupEanLookup($value);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling BarcodeLookupApi->barcodeLookupEanLookup: ', $e->getMessage(), PHP_EOL;
}
?>

Each request will return details about the product matching the input EAN value. Simple as that!

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.