nieknijland / autoscout24-php
PHP client for AutoScout24.nl — wraps internal Next.js data endpoints into a typed API
Package info
github.com/NiekNijland/autoscout24-php
Language:HTML
pkg:composer/nieknijland/autoscout24-php
Fund package maintenance!
Requires
- php: ^8.4
- guzzlehttp/guzzle: ^7.10
- psr/simple-cache: ^3.0
Requires (Dev)
- laravel/pint: ^1.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.3.2
- rector/rector: ^2.0
- spatie/ray: ^1.28
README
A PHP client for AutoScout24.nl that wraps internal Next.js data endpoints into a typed API. Supports searching for cars and motorcycles, fetching listing details, and retrieving filter taxonomy data (brands, models, body types, fuel types, etc.).
Installation
You can install the package via composer:
composer require nieknijland/autoscout24-php
Usage
Search for cars
use NiekNijland\AutoScout24\AutoScout24; use NiekNijland\AutoScout24\Data\CarSearchCriteria; use NiekNijland\AutoScout24\Data\Filters\SharedSearchFilters; use NiekNijland\AutoScout24\Data\SortOrder; $client = new AutoScout24(); // Basic search with defaults $result = $client->search(new CarSearchCriteria()); foreach ($result->listings as $listing) { echo "{$listing->vehicle->make} {$listing->vehicle->model} - {$listing->price->priceFormatted}\n"; } // Search with filters $result = $client->search(CarSearchCriteria::fromFilters( shared: new SharedSearchFilters( priceFrom: 5000, priceTo: 20000, sortOrder: SortOrder::PriceAscending, ), ));
Search for motorcycles
use NiekNijland\AutoScout24\Data\MotorcycleSearchCriteria; $result = $client->search(new MotorcycleSearchCriteria());
Auto-paginate through all results
// Lazily iterate through all pages foreach ($client->searchAll(new CarSearchCriteria(), delayMs: 200) as $listing) { echo "{$listing->vehicle->make} {$listing->vehicle->model}\n"; }
Get listing details
$detail = $client->getDetailBySlug('volkswagen-polo-tsi-abc123'); echo $detail->vehicle->make; // "Volkswagen" echo $detail->prices->public->price; // "€ 15.990" echo $detail->descriptionText(); // Plain text (HTML stripped)
Brands and filter options
use NiekNijland\AutoScout24\Data\VehicleType; $brands = $client->getBrands(VehicleType::Car); $models = $client->getModels(VehicleType::Car, $brands[0]); $bodyTypes = $client->getFilterOptions(VehicleType::Car, 'bodyType');
Caching
Pass a PSR-16 cache to avoid refetching the build ID on every request:
$client = new AutoScout24( cache: $yourPsr16Cache, cacheTtl: 3600, );
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.