PHP code example of vindecodervehicle / php-sdk

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

    

vindecodervehicle / php-sdk example snippets




use VinDecoderVehicle\Sdk\VinDecoderClient;

$client = VinDecoderClient::create(
    user: 'YOUR_USER',
    apiKey: 'YOUR_API_KEY',
);

// Decode a VIN
$vehicle = $client->vin()->decode('WF0GXXGAJ69C71882');

echo $vehicle->getFullName(); // BMW 3 Coupe (E92) 316 i
echo $vehicle->make;        // BMW
echo $vehicle->year;        // 2007
echo $vehicle->carId;       // 55565

// First matching vehicle
$vehicle = $client->vin()->decode('WF0GXXGAJ69C71882');

// All matching vehicles
$vehicles = $client->vin()->decodeAll('WF0GXXGAJ69C71882');

// Engine details
$engines = $client->vin()->getEngines('WF0GXXGAJ69C71882');

$vehicle = $client->vehicle()->getById(55565);
$fluids  = $client->vehicle()->getFluidCapacities(55565);
$parts   = $client->vehicle()->getOemParts(55565);
$repairs = $client->vehicle()->getRepairTimes(55565); // plan-dependent

$brands   = $client->catalog()->listBrands();
$models   = $client->catalog()->listModels('bmw');
$variants = $client->catalog()->listVariants('bmw', '3-series');

use VinDecoderVehicle\Sdk\Exception\ApiException;
use VinDecoderVehicle\Sdk\Exception\AuthenticationException;
use VinDecoderVehicle\Sdk\Exception\InvalidArgumentException;

try {
    $vehicle = $client->vin()->decode('INVALID');
} catch (InvalidArgumentException $e) {
    // Invalid VIN format
} catch (AuthenticationException $e) {
    // Invalid user or API key
} catch (ApiException $e) {
    // API error (quota, plan limits, etc.)
    echo $e->getMessage();
    print_r($e->getResponseBody());
}
bash
composer 
bash
export VINDECODER_USER=your_user
export VINDECODER_KEY=your_api_key
php examples/decode-vin.php WF0GXXGAJ69C71882
bash
git clone https://github.com/JoxMarkes/vindecodervehicle-php-sdk.git
cd vindecodervehicle-php-sdk
composer install
composer test