PHP code example of trackstone / immo-data-php-sdk
1. Go to this page and download the library: Download trackstone/immo-data-php-sdk 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/ */
trackstone / immo-data-php-sdk example snippets
use ImmoData\ImmoDataClient;
use ImmoData\Enums\RealtyType;
use ImmoData\Requests\ValuationRequest;
$client = new ImmoDataClient(apiKey: 'your-api-key');
$request = new ValuationRequest(
longitude: 2.3488,
latitude: 48.8534,
realtyType: RealtyType::Apartment,
nbRooms: 3,
livingArea: 65.0,
);
$result = $client->valuation()->estimate($request);
echo $result->mainValuation; // 485000.0
echo $result->confidence; // 4
use ImmoData\ImmoDataClient;
// Default (production)
$client = new ImmoDataClient(apiKey: 'your-api-key');
// Custom base URL (staging, etc.)
$client = new ImmoDataClient(
apiKey: 'your-api-key',
baseUrl: 'https://staging-api.immo-data.fr',
);
// Custom HTTP client (for testing or custom transport)
$client = new ImmoDataClient(
apiKey: 'your-api-key',
httpClient: new YourCustomHttpClient(),
);
use ImmoData\Enums\{GeoLevel, RealtyType};
// Price history for Paris apartments
$history = $client->market()->priceHistory(
code: '75056',
geoLevel: GeoLevel::City,
realtyType: RealtyType::Apartment,
startDate: '2020-01-01',
endDate: '2024-12-31',
);
echo $history->metric; // "sqm_price"
foreach ($history->data as $point) {
echo "{$point->period}: {$point->value} EUR/m²";
}
// Current price for a department
$price = $client->market()->currentPrice(
code: '75',
geoLevel: GeoLevel::Department,
realtyType: RealtyType::Apartment,
);
echo $price->value; // 10234.5 (EUR/m², null if no data available)
use ImmoData\Enums\{GeoLevel, DurationUnit};
// History of the average sale duration for a city
$history = $client->market()->saleDurationHistory(
code: '75114',
geoLevel: GeoLevel::City,
startDate: '2022-01',
endDate: '2024-12',
unit: DurationUnit::Days,
);
echo $history->unit; // "days"
foreach ($history->data as $point) {
echo "{$point->period}: {$point->value} days";
}
// Current average sale duration for a department
$current = $client->market()->currentSaleDuration(
code: '75',
geoLevel: GeoLevel::Department,
unit: DurationUnit::Months,
);
echo $current->unit; // "months"
echo $current->value; // 3.0 (null if no data available)
use ImmoData\Enums\{GeoLevel, Dpe, RealtyType, DpeSortBy, SortOrder};
use ImmoData\Requests\DpeRequest;
$result = $client->dpe()->search(new DpeRequest(
code: '75114',
geoLevel: GeoLevel::City,
dpeRating: [Dpe::F, Dpe::G], // energy label (étiquette énergie)
gesRating: [Dpe::E, Dpe::F, Dpe::G], // climate label (étiquette climat)
realtyType: [RealtyType::Apartment],
sortBy: DpeSortBy::Date,
sortOrder: SortOrder::Desc,
size: 20,
));
echo $result->total;
foreach ($result->data as $dpe) {
echo $dpe->dpeNumber; // "2375E1234567A"
echo $dpe->dpeRating; // "D"
echo $dpe->energyConsFinal; // 180.5 (kWh/m²/an)
echo $dpe->location?->address?->cityName;
echo $dpe->realty?->realtyType; // "apartment"
}
// Next page
$next = $client->dpe()->search(new DpeRequest(
code: '75114',
geoLevel: GeoLevel::City,
searchAfter: $result->searchAfter,
));
// Retrieve a single DPE by its ADEME number
$dpe = $client->dpe()->get('2375E1234567A');
echo $dpe->dpeRating; // "D"