PHP code example of macropage / idealo-business-api

1. Go to this page and download the library: Download macropage/idealo-business-api 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/ */

    

macropage / idealo-business-api example snippets


use IdealoBusiness\IdealoBusinessConnector;
use IdealoBusiness\Data\ClickReportStatus;

$idealo = new IdealoBusinessConnector(
    clientId:     getenv('IDEALO_CLIENT_ID'),
    clientSecret: getenv('IDEALO_CLIENT_SECRET'),
);

// First request triggers auto-auth via boot(). You can also call it explicitly:
$idealo->authenticateWithClientCredentials();

// idealo returns the shop_id directly in the token response for single-shop credentials:
$shopId = $idealo->getAuthenticatedShopId();

$response = $idealo->clickReports()->start(
    shopId: $shopId,
    from:   '2026-04-20', // YYYY-MM-DD, optional
    to:     '2026-04-22', // YYYY-MM-DD, optional
);

$data = $response->json();
// $data = ['status' => 'PROCESSING', 'startTime' => '...', 'id' => '<uuid>',
//          'shopId' => 12345, 'from' => '2026-04-20', 'to' => '2026-04-22']

$reportId = $data['id'];

$response = $idealo->clickReports()->get($shopId, $reportId);
$data     = $response->json();

$status = ClickReportStatus::from($data['status']);
// ClickReportStatus::Processing | Failed | Successful

$response = $idealo->clickReports()->download($shopId, $reportId);

// Always treat this as binary. Do NOT call ->json().
file_put_contents("report_{$reportId}.zip", $response->body());

$zip = new ZipArchive();
$zip->open("report_{$reportId}.zip");
$csv = $zip->getFromIndex(0);

$idealo = new IdealoBusinessConnector($clientId, $clientSecret);
// Optional 3rd arg: $baseUrl (defaults to https://businessapi.idealo.com)

$idealo->authenticateWithClientCredentials(): self
$idealo->getAuthenticatedShopId(): ?int   // from token response
$idealo->getTokenScope(): ?string
$idealo->getTokenType(): ?string

$idealo->clickReports()->start(int $shopId, ?string $from = null, ?string $to = null): Response
$idealo->clickReports()->get(int $shopId, string $reportId): Response
$idealo->clickReports()->download(int $shopId, string $reportId): Response