codebyray/laravel-vehapi

Vehicle Information API Laravel Package

1.1.1 2021-12-21 05:02 UTC

This package is auto-updated.

Last update: 2024-10-21 11:20:29 UTC


README

Packagist Version Build Status Quality Score Total Downloads

Vehicle Information API is an API system for retrieving vehicle information to include, vehicle year, make, model, trim, transmission, engine and logos for vehicle makes. For more information on this service or to subscribe, please visit Vehicle Information API

NOTE: This package currently only works to retrieve vehicle data from our API, it will not work to retrieve ANY data from our MOTO API endpoints. We will be adding that ability in a future release.

Installation

You can install the package via composer:

composer require codebyray/laravel-vehapi

Then include the service provider within you app/config/app.php.

NOTE: If you're running Laravel 5.5+ this will be auto loaded for you.

'providers' => [
    Codebyray\LaravelVehapi\LaravelVehapiServiceProvider::class
];

Publish the config file (optional)

php artisan vendor:publish --provider="Codebyray\LaravelVehapi\LaravelVehapiServiceProvider" --tag="config"

Setup .env file

Add your API token, API version & API SSL check to your .env file:

NOTE: API version will default to v1, you DO NOT need to specify the version unless you are using a different version of Vehicle Info API. API token is required. However, it can be entered in your .env file (recommended), or the published config file.

VEH_API_TOKEN=YOUR_VEH_API_TOKEN
VEH_API_VERSION=v1
VEH_CHECK_SSL_CERT=true // Defaults to true. Change to false if testing locally.

Usage

Let's get all the distinct years for all the makes available

/**
 * @param string $sort - optional, defaults to 'asc'
 */
LaravelVehapi::getAllYears($sort = 'asc');

// Returns associative array
// This will return all years from 1899-2022
$vehYears = LaravelVehapi::getAllYears($sort);

// Convert array to json format
$vehYears = json_encode(LaravelVehapi::getAllYears($sort));

Let's get all the distinct years for all the makes available

/**
 * @param int $minYear - required
 * @param int $maxYear - required
 * @param string $sort - optional, defaults to 'asc'
 */
LaravelVehapi::getYearsRange(int $minYear, int $maxYear, $sort = 'asc');

// Returns associative array
$vehYears = LaravelVehapi::getYearsRange('2010', '2014', 'desc');

// Convert array to json format
$vehYears = json_encode(LaravelVehapi::getYearsRange('2010', '2014', 'desc'));

Let's get all the distinct makes available

/**
 * @param string $sort - optional, defaults to 'asc'
 */
LaravelVehapi::getAllMakes($sort = 'asc');

// Returns associative array
$vehMakes = LaravelVehapi::getAllMakes();

// Convert array to json format
$vehMakes = json_encode(LaravelVehapi::getAllMakes());

Let's get all the distinct makes available for a specific year

/**
 * @param int $year - required
 * @param string $sort - optional, defaults to 'asc'
 */
LaravelVehapi::getMakesByYear($year, $sort = 'asc');

// Returns associative array
$vehMakes = LaravelVehapi::getMakesByYear(2015);

// Convert array to json format
$vehMakes = json_encode(LaravelVehapi::getMakesByYear(2015));

Let's get all the distinct makes available for a specific year range

/**
 * @param int $minYear - required
 * @param int $maxYear - required
 * @param string $sort - optional, defaults to 'asc'
 */
LaravelVehapi::getMakesByYearsRange($minYear, $maxYear, $sort = 'asc');

// Returns associative array
$vehMakes = LaravelVehapi::getMakesByYear(2015);

// Convert array to json format
$vehMakes = json_encode(LaravelVehapi::getMakesByYear(2015));

Let's get all the models available for a specific make

/**
 * @param string $make - required
 * @param string $sort - optional, defaults to 'asc'
 */
LaravelVehapi::getAllModelsByMake($make, $sort = 'asc');

// Returns associative array
$vehModels = LaravelVehapi::getAllModelsByMake('Acura');

// Convert array to json format
$vehModels = json_encode(LaravelVehapi::getAllModelsByMake('Acura'));

Let's get all the models available for a specific year & make

/**
 * @param int $year - required
 * @param string $make - required
 * @param string $sort - optional, defaults to 'asc'
 */
LaravelVehapi::getModelsByYearAndMake($year, $make, $sort = 'asc');

// Returns associative array
$vehModels = LaravelVehapi::getModelsByYearAndMake(2015, 'Acura');

// Convert array to json format
$vehModels = json_encode(LaravelVehapi::getModelsByYearAndMake(2015, 'Acura'));

Let's get all the trims levels available for a specific year, make & model

/**
 * @param int $year - required
 * @param string $make - required
 * @param string $model - required
 */
LaravelVehapi::getTrimsByYearMakeAndModel($year, $make, $model);

// Returns associative array
$vehTrims = LaravelVehapi::getTrimsByYearMakeAndModel(2015, 'Acura', 'MDX');

// Convert array to json format
$vehTrims = json_encode(LaravelVehapi::getTrimsByYearMakeAndModel(2015, 'Acura', 'MDX'));

Let's get all the transmissions available for a specific year, make, model & trim

/**
 * @param int $year - required
 * @param string $make - required
 * @param string $model - required
 * @param string $trim - required
 */
LaravelVehapi::getTransmissionsByYearMakeModelAndTrim($year, $make, $model, $trim);

// Returns associative array
$vehTransmissions = LaravelVehapi::getTransmissionsByYearMakeModelAndTrim(2015, 'Acura', 'MDX', 'FWD');

// Convert array to json format
$vehTransmissions = json_encode(LaravelVehapi::getTransmissionsByYearMakeModelAndTrim(2015, 'Acura', 'MDX', 'FWD'));

Let's get all the engines available for a specific year, make, model, trim & transmission

/**
 * @param int $year - required
 * @param string $make - required
 * @param string $model - required
 * @param string $trim - required
 * @param string $transmission - required
 */
LaravelVehapi::getEnginesByYearMakeModelTrimAndTransmission($year, $make, $model, $trim, $transmission);

// Returns associative array
$vehEngines = LaravelVehapi::getEnginesByYearMakeModelTrimAndTransmission(2015, 'Acura', 'MDX', 'FWD', '6-Speed Automatic');

// Convert array to json format
$vehEngines = json_encode(LaravelVehapi::getEnginesByYearMakeModelTrimAndTransmission(2015, 'Acura', 'MDX', 'FWD', '6-Speed Automatic'));

Let's get all the wheel options available for a specific year, make, model, trim, transmission & engine

/**
 * Return wheels available for the year, make, model, transmission & engine supplied.
 *
 * @param int $year
 * @param string $make
 * @param string $model
 * @param string $trim
 * @param string $transmission
 * @param string $engine
 *
 * @return mixed
 */
LaravelVehapi::getWheelsByYearMakeModelTrimTransmissionAndEngine($year, $make, $model, $trim, $transmission, $engine);

// Returns associative array
$vehWheels = LaravelVehapi::getWheelsByYearMakeModelTrimTransmissionAndEngine(2021, 'Acura', 'TLX', 'FWD', '10-Speed Automatic', '2.0L 272 hp I4');

// Convert array to json format
$vehWheels = json_encode(LaravelVehapi::getWheelsByYearMakeModelTrimTransmissionAndEngine(2021, 'Acura', 'TLX', 'FWD', '10-Speed Automatic', '2.0L 272 hp I4'));

Let's get all the vehicle options available for a specific year, make, model, trim, transmission & engine

/**
 * Return options available for the year, make, model, transmission & engine supplied.
 *
 * @param int $year
 * @param string $make
 * @param string $model
 * @param string $trim
 * @param string $transmission
 * @param string $engine
 *
 * @return mixed
 */
LaravelVehapi::getOptionsByYearMakeModelTrimTransmissionAndEngine($year, $make, $model, $trim, $transmission, $engine);

// Returns associative array
$vehOptions = LaravelVehapi::getOptionsByYearMakeModelTrimTransmissionAndEngine(2021, 'Acura', 'TLX', 'FWD', '10-Speed Automatic', '2.0L 272 hp I4');

// Convert array to json format
$vehOptions = json_encode(LaravelVehapi::getOptionsByYearMakeModelTrimTransmissionAndEngine(2021, 'Acura', 'TLX', 'FWD', '10-Speed Automatic', '2.0L 272 hp I4'));

Changelog

Please see CHANGELOG for more information what has changed recently.

API Documentation

For a complete list of available API endpoints, visit API documentation

Security

If you discover any security related issues, please email dev@codebyray.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.