amattu2/nhtsa-wrapper
Composer 安装命令:
composer require amattu2/nhtsa-wrapper
包简介
A simple PHP based NHTSA (U.S. Department of Transportation) vehicle VIN decoder and Recall lookup API wrapper.
README 文档
README
This is a simple VIN decoder wrapper for the NHTSA (United States Department of Transportation) VIN decoder API. Additionally, it includes the NHTSA vehicle recall API. See usage section below or the example index.php file.
Usage
Import
Install with composer
require amattu2/nhtsa-wrapper
require "vendor/autoload.php";
VIN Decode
Raw Decode
PHPDoc
/** * 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 */
Usage
$decode = amattu2\NHTSA\Client::decodeVIN("VIN_NUMBER");
Success return result
Array ( [Error Text] => [Make] => [Manufacturer Name] => [Model] => [Model Year] => [Plant City] => [Series] => [Trim] => [Vehicle Type] => [Plant Country] => ... )
Pretty Decode
PHPDoc
/** * 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 */
Usage
$decode = amattu2\NHTSA\Client::decodeVIN("VIN_NUMBER"); $pretty_decode = amattu2\NHTSA\Client::parseDecode($decode);
Success return result (Example)
Array ( [Model_Year] => 2011 [Make] => MERCEDES-BENZ [Model] => M-CLASS [Trim] => 4-MATIC [Engine] => 3.5L 6-CYL (3,500CC) )
Recalls
Raw Recalls
PHPDoc
/** * 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 */
Usage
$recalls = amattu2\NHTSA\Client::getRecalls(2015, "Ford", "Mustang");
Success return result
Array
(
[0] => Array
(
[Manufacturer] =>
[NHTSACampaignNumber] =>
[ReportReceivedDate] =>
[Component] =>
[Summary] =>
[Conequence] =>
[Remedy] =>
[Notes] =>
[ModelYear] =>
[Make] =>
[Model] =>
)
...
)
Pretty Recalls
PHPDoc
/** * 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 */
Usage
$recalls = amattu2\NHTSA\Client::getRecalls(2015, "Ford", "Mustang"); $pretty_recalls = amattu2\NHTSA\Client::parseRecalls($recalls);
Success return result
Array
(
[2] => Array
(
[Campaign_Number] =>
[Component] => Array
(
[0] => FUEL SYSTEM, GASOLINE
[1] => STORAGE
[2] => TANK ASSEMBLY /* The last element is the actual component */
)
[Date] => 2015-06-02
[Description] =>
[Remedy] =>
)
...
)
getModelsForMakeByYear
PHPDoc
/** * 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 */
Usage
$models = amattu2\NHTSA\Client::getModelsForMakeByYear(2015, "Ford");
Success return result
Array
(
[0] => Array
(
[Make_ID] => 441
[Make_Name] => FORD
[Model_ID] => 2021
[Model_Name] => C-MAX
)
...
)
getModelsForMakeIdByYear
PHPDoc
/** * Get all available models for a make by year * * @param int $year The model year * @param int $make_id The make ID */
Usage
$models = amattu2\NHTSA\Client::getModelsForMakeIdByYear(2015, 441);
Success return result
Array
(
[0] => Array
(
[Make_ID] => 441
[Make_Name] => FORD
[Model_ID] => 2021
[Model_Name] => C-MAX
)
...
)
getModelsForMake
PHPDoc
/** * Get all available models for a make * * @param string $make The make */
Usage
$models = amattu2\NHTSA\Client::getModelsForMake("Ford");
Success return result
Array
(
[0] => Array
(
[Make_ID] => 441
[Make_Name] => FORD
[Model_ID] => 2021
[Model_Name] => C-MAX
)
...
)
getModelsForMakeId
PHPDoc
/** * Get all available models for a make * * @param int $make_id The make ID */
Usage
$models = amattu2\NHTSA\Client::getModelsForMakeId(441);
Success return result
Array
(
[0] => Array
(
[Make_ID] => 441
[Make_Name] => FORD
[Model_ID] => 2021
[Model_Name] => C-MAX
)
...
)
Requirements & Dependencies
- PHP 7.4+
- cURL Extension
amattu2/nhtsa-wrapper 适用场景与选型建议
amattu2/nhtsa-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 563 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 amattu2/nhtsa-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amattu2/nhtsa-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 563
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 37
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: AGPL-3.0
- 更新时间: 2023-03-09