PHP code example of amattu2 / nhtsa-wrapper

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

    

amattu2 / nhtsa-wrapper example snippets




/**
 * Decode a 17-digit VIN
 *
 * @param string vin number
 * @param ?integer model year
 * @return ?array raw NHTSA result
 * @throws TypeError
 * @author Alec M. <https://amattu.com>
 * @date 2021-04-04T16:19:40-040
 */

$decode = amattu2\NHTSA\Client::decodeVIN("VIN_NUMBER");

/**
* Parse a raw decode call
* Converts a decodeVIN call into a pretty parsed Year, Make, Model, Trim, Engine array
*
* @param array raw decode result
* @return ?array pretty parsed NHTSA result
* @throws TypeError
* @author Alec M. <https://amattu.com>
* @date 2021-04-04T16:52:15-040
*/

$decode = amattu2\NHTSA\Client::decodeVIN("VIN_NUMBER");
$pretty_decode = amattu2\NHTSA\Client::parseDecode($decode);

Array
(
  [Model_Year] => 2011
  [Make] => MERCEDES-BENZ
  [Model] => M-CLASS
  [Trim] =>  4-MATIC
  [Engine] => 3.5L 6-CYL (3,500CC)
)

/**
 * Get vehicle recalls by Year, Make, Model
 *
 * @param int model year
 * @param string make
 * @param string model
 * @return ?array NHTSA raw result
 * @throws TypeError
 * @author Alec M. <https://amattu.com>
 * @date 2021-04-04T16:48:24-040
 */

$recalls = amattu2\NHTSA\Client::getRecalls(2015, "Ford", "Mustang");

/**
 * Parse a raw recall result
 *
 * @param array raw recall result
 * @return ?array parsed recall result
 * @throws TypeError
 * @author Alec M. <https://amattu.com>
 * @date 2021-04-04T18:16:26-040
*/

$recalls = amattu2\NHTSA\Client::getRecalls(2015, "Ford", "Mustang");
$pretty_recalls = amattu2\NHTSA\Client::parseRecalls($recalls);

/**
 * Get all available models for a make by year
 *
 * @note This is a free-text match. Recommend using `getModelsForMakeIdByYear`
 * @param int $year The model year
 * @param string $make The make
 */

$models = amattu2\NHTSA\Client::getModelsForMakeByYear(2015, "Ford");

/**
 * Get all available models for a make by year
 *
 * @param int $year The model year
 * @param int $make_id The make ID
 */

$models = amattu2\NHTSA\Client::getModelsForMakeIdByYear(2015, 441);

/**
 * Get all available models for a make
 *
 * @param string $make The make
 */

$models = amattu2\NHTSA\Client::getModelsForMake("Ford");

/**
 * Get all available models for a make
 *
 * @param int $make_id The make ID
 */

$models = amattu2\NHTSA\Client::getModelsForMakeId(441);