1. Go to this page and download the library: Download asm/eprel-api-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
asm / eprel-api-client example snippets
use Asm\EprelApiClient\EprelClient;
// Using the Fluent API (Recommended)
$client = (new EprelClient())
->uri('https://eprel.ec.europa.eu/api')
->apiKey('your-api-key') // If eu/api',
'cacheTtl' => 3600,
]);
use Asm\EprelApiClient\Exception\ResourceNotFoundException;
try {
$productDetail = $client->getProduct('123456');
echo "Brand: " . $productDetail->brandName . "\n";
echo "Label URL: " . $productDetail->energyLabelUrl . "\n";
echo "Product Sheet URL: " . $productDetail->productInformationSheetUrl . "\n";
// Access arbitrary technical parameters provided by the API
if (isset($productDetail->technicalParameters['volume'])) {
echo "Volume: " . $productDetail->technicalParameters['volume'] . " L\n";
}
} catch (ResourceNotFoundException $e) {
echo "Product not found in the EPREL database.";
} catch (\Throwable $e) {
echo "An API error occurred: " . $e->getMessage();
}
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Asm\EprelApiClient\EprelClient;
$redisConnection = RedisAdapter::createConnection('redis://localhost');
$cachePool = new RedisAdapter($redisConnection);
$client = (new EprelClient())
->setCache($cachePool)
->cacheTtl(86400); // Cache for 24 hours
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.