Package: pvaw
PVAW: Python Vehicle API WrapperA Python wrapper for theNational Highway Traffic Saftey Association(NHTSA)Vehicle APILicenseDocumentationIstalling PVAWpipinstallpvawImporting PVAWimportpvawaspvVin DecodingThe NHTSA Vehicle API supports individual and batch decoding.Vin Classclass pvaw.Vin(full_or_partial_vin, model_year=None)Parameters:full_or_partial_vin:string representing a Vehicle Identification Number (VIN). It can be either the full VIN (e.g. "3C6JR7AT4EG248404"), or be a subset of the VIN with missing characters replaced by the '*' character (e.g. "5YJSA3DS*EF")model_year:string or integer representing the model year of the vehicle. Defaults to None.Constructing a Vin# creating a Vin object from partial vinvin_1=pv.Vin("5YJSA3DS*EF")# creationg a Vin object from partial vin and yearvin_2=pv.Vin("5UXWX7C5*BA",2011)Decoding a Vinpvaw.Vin.decode()Returns:A Vehicle object with information about the Vin's associated vehiclevehicle=vin_1.decode()vehiclemodel_yearmakemanufacturermodelfull_or_partial_vinvehicle_type5YJSA3DS*EF2014TESLATESLA, INC.Model S5YJSA3DS*EFPASSENGER CARGetting Key Attributesprint(vehicle.model_year)print(vehicle.make)print(vehicle.manufacturer)print(vehicle.model)print(vehicle.full_or_partial_vin)print(vehicle.vehicle_type)2014
TESLA
TESLA, INC.
Model S
5YJSA3DS*EF
PASSENGER CARGetting JSON Resultsvehicle.get_results(){'ABS': '',
 'ActiveSafetySysNote': '',
 'AdaptiveCruiseControl': '',
 'AdaptiveDrivingBeam': '',
 'AdaptiveHeadlights': '',
 'AdditionalErrorText': 'The error positions are indicated by ! in Suggested VIN. In the Possible values section, each pair of parenthesis indicate information about each error position in VIN . The Numeric value before the : indicates the position in error and the values after the : indicate the possible values that are allowed in this position Unused position(s): 8;',
 'AirBagLocCurtain': '',
 'AirBagLocFront': '1st Row (Driver & Passenger)',
 ...Getting DataFrame# Getting key attribute df dropping nanvehicle.get_df()model_yearmakemanufacturermodelfull_or_partial_vinvehicle_type5YJSA3DS*EF2014TESLATESLA, INC.Model S5YJSA3DS*EFPASSENGER CAR# Getting full raw data df not dropping nanvehicle.get_df(raw=True,drop_na=False)ABSActiveSafetySysNoteAdaptiveCruiseControlAdaptiveDrivingBeamAdaptiveHeadlightsAdditionalErrorTextAirBagLocCurtainAirBagLocFrontAirBagLocKneeAirBagLocSeatCushion...VINValveTrainDesignVehicleTypeWheelBaseLongWheelBaseShortWheelBaseTypeWheelSizeFrontWheelSizeRearWheelsWindows5YJSA3DS*EFNaNNaNNaNNaNNaNThe error positions are indicated by ! in Sugg...NaN1st Row (Driver & Passenger)1st Row (Driver & Passenger)NaN...5YJSA3DS*EFNaNPASSENGER CARNaNNaNNaNNaNNaNNaNNaN1 rows × 145 columnsBatch Decodingpvaw.decode_vins(vins)Parameters:vins:list of Vin objectsReturns:ResultsList object which stores a list of Vehicle objectsvehicles=pv.decode_vins([vin_1,vin_2])vehiclesmodel_yearmakemanufacturermodelfull_or_partial_vinvehicle_type5YJSA3DS*EF2014TESLATESLA, INC.Model S5YJSA3DS*EFPASSENGER CAR5UXWX7C5*BA,20112011BMWBMW MANUFACTURER CORPORATION / BMW NORTH AMERICAX35UXWX7C5*BAMULTIPURPOSE PASSENGER VEHICLE (MPV)Accessing each Vehicle# Iterating through vehiclesforvehicleinvehicles:display(vehicle)# Indexing Vehiclesfirst=vehicles[0]last=vehicles[len(vehicles)-1]model_yearmakemanufacturermodelfull_or_partial_vinvehicle_type5YJSA3DS*EF2014TESLATESLA, INC.Model S5YJSA3DS*EFPASSENGER CARmodel_yearmakemanufacturermodelfull_or_partial_vinvehicle_type5UXWX7C5*BA,20112011BMWBMW MANUFACTURER CORPORATION / BMW NORTH AMERICAX35UXWX7C5*BAMULTIPURPOSE PASSENGER VEHICLE (MPV)Getting JSON Resultsvehicles.get_results()[{'ABS': '',
  'ActiveSafetySysNote': '',
  'AdaptiveCruiseControl': '',
  'AdaptiveDrivingBeam': '',
  'AdaptiveHeadlights': '',
  'AdditionalErrorText': 'The error positions are indicated by ! in Suggested VIN. In the Possible values section, each pair of parenthesis indicate information about each error position in VIN . The Numeric value before the : indicates the position in error and the values after the : indicate the possible values that are allowed in this position Unused position(s): 8;',
  'AirBagLocCurtain': '',
  'AirBagLocFront': '1st Row (Driver & Passenger)',
  'AirBagLocKnee': '1st Row (Driver & Passenger)',
  'AirBagLocSeatCushion': '',
  ...Getting DataFrame# Getting key attribute df dropping nanvehicles.get_df()model_yearmakemanufacturermodelfull_or_partial_vinvehicle_type5YJSA3DS*EF2014TESLATESLA, INC.Model S5YJSA3DS*EFPASSENGER CAR5UXWX7C5*BA,20112011BMWBMW MANUFACTURER CORPORATION / BMW NORTH AMERICAX35UXWX7C5*BAMULTIPURPOSE PASSENGER VEHICLE (MPV)# Getting full raw data df not dropping nanvehicles.get_df(raw=True,drop_na=False)ABSActiveSafetySysNoteAdaptiveCruiseControlAdaptiveDrivingBeamAdaptiveHeadlightsAdditionalErrorTextAirBagLocCurtainAirBagLocFrontAirBagLocKneeAirBagLocSeatCushion...VINValveTrainDesignVehicleTypeWheelBaseLongWheelBaseShortWheelBaseTypeWheelSizeFrontWheelSizeRearWheelsWindows5YJSA3DS*EFNaNNaNNaNNaNNaNThe error positions are indicated by ! in Sugg...NaN1st Row (Driver & Passenger)1st Row (Driver & Passenger)NaN...5YJSA3DS*EFNaNPASSENGER CARNaNNaNNaNNaNNaNNaNNaN5UXWX7C5*BA,2011NaNNaNNaNNaNNaNNaNNaN1st Row (Driver & Passenger)NaNNaN...5UXWX7C5*BANaNMULTIPURPOSE PASSENGER VEHICLE (MPV)NaNNaNNaNNaNNaNNaNNaN2 rows × 145 columnsWMI MethodsThe NHTSA Vehicle API supports wmi decodingWMI Decodingpvaw.decode_wmi(wmi)Parameters: wmi:str of length 3 representing VIN position 1-3 (e.g. "1FD") or 6 representing VIN positions 1-3 & 12-14 (e.g. "1G9340")Returns:WMIInfo object with information on wmiwmi_info=pv.decode_wmi("JTL")wmi_infowmivehicle_typemanufacturerJTLJTLMultipurpose Passenger Vehicle (MPV)TOYOTA MOTOR NORTH AMERICA, INCGetting Key Attributesprint(wmi_info.wmi)print(wmi_info.manufacturer)print(wmi_info.vehicle_type)JTL
TOYOTA MOTOR NORTH AMERICA, INC
Multipurpose Passenger Vehicle (MPV)Getting JSON Resultswmi_info.get_results(){'CommonName': 'Toyota',
 'CreatedOn': '2015-05-04',
 'DateAvailableToPublic': '2015-01-01',
 'Make': 'TOYOTA',
 'ManufacturerName': 'TOYOTA MOTOR NORTH AMERICA, INC',
 'ParentCompanyName': 'TOYOTA MOTOR CORPORATION',
 'URL': 'http://www.toyota.com',
 'UpdatedOn': None,
 'VehicleType': 'Multipurpose Passenger Vehicle (MPV)',
 'WMI': 'JTL'}Getting DataFrame# Getting key attribute df dropping nanwmi_info.get_df()wmivehicle_typemanufacturerJTLJTLMultipurpose Passenger Vehicle (MPV)TOYOTA MOTOR NORTH AMERICA, INC# Getting full raw data df not dropping nanwmi_info.get_df(raw=True,drop_na=False)CommonNameCreatedOnDateAvailableToPublicMakeManufacturerNameParentCompanyNameURLUpdatedOnVehicleTypeWMIJTLToyota2015-05-042015-01-01TOYOTATOYOTA MOTOR NORTH AMERICA, INCTOYOTA MOTOR CORPORATIONhttp://www.toyota.comNoneMultipurpose Passenger Vehicle (MPV)JTLFinding WMIs by Manufacturerpvaw.get_wmis(manufacturer_search)Parameters: manufacturer_search:a str representing part or all of the name of a Manufacturer (e.g. "Honda")Returns:ResultsList object which stores a list of WMIInfo objectswmi_infos=pv.get_wmis("Tesla")wmi_infoswmivehicle_typemanufacturer5YJ5YJPassenger CarTESLA, INC.SFZSFZPassenger CarTESLA, INC.Accessing Each WMI# Iterating through vehiclesforwmi_infoinwmi_infos:display(wmi_info)# Indexing Vehiclesfirst=wmi_infos[0]last=wmi_infos[len(vehicles)-1]# Getting Key Attributesprint(first.wmi)print(first.manufacturer)print(first.vehicle_type)wmivehicle_typemanufacturer5YJ5YJPassenger CarTESLA, INC.wmivehicle_typemanufacturerSFZSFZPassenger CarTESLA, INC.5YJ
TESLA, INC.
Passenger CarGetting JSON Resultswmi_infos.get_results()[{'Country': 'UNITED STATES (USA)',
  'CreatedOn': '2015-03-04',
  'DateAvailableToPublic': '2015-01-01',
  'Id': 955,
  'Name': 'TESLA, INC.',
  'UpdatedOn': None,
  'VehicleType': 'Passenger Car',
  'WMI': '5YJ'},
 {'Country': 'UNITED STATES (USA)',
  'CreatedOn': '2015-04-16',
  'DateAvailableToPublic': '2015-01-01',
  'Id': 955,
  'Name': 'TESLA, INC.',
  'UpdatedOn': None,
  'VehicleType': 'Passenger Car',
  'WMI': 'SFZ'}]Getting DataFrame# Getting key attribute df dropping nanwmi_infos.get_df()wmivehicle_typemanufacturer5YJ5YJPassenger CarTESLA, INC.SFZSFZPassenger CarTESLA, INC.# Getting full raw data df not dropping nanwmi_infos.get_df(raw=True,drop_na=False)CountryCreatedOnDateAvailableToPublicIdNameUpdatedOnVehicleTypeWMI5YJUNITED STATES (USA)2015-03-042015-01-01955TESLA, INC.NonePassenger Car5YJSFZUNITED STATES (USA)2015-04-162015-01-01955TESLA, INC.NonePassenger CarSFZMake Methodspvaw.get_makes(manufacturer_name_or_id=None, model_year=None, vehicle_type=None)Finding Makes by Manufacturer and Year or Vehicle TypeParameters: manufacturer_name_or_id:a str representing part or all of the name of a manufacturer (e.g. "Honda") or an integer representing the manufacturer IDmodel_year:a str or int representing the year makes must exist in (e.g. 2005)vehicle_type:a str representing the type of vehicle that a make produces (e.g. "car")NOTE: For this method, you can filter either by manufacturer_name_or_id or by vehicle_type, you cannot filter by both. Additionally, model_year can be passed in with manufacturer_name_or_id, but not with vehicle_type.Returns:ResultsList object which stores a list of Make objects# getting makes for manufacturer name searchmakes=pv.get_makes("hyundai")# getting makes for manufacturer name search and model yearmakes_2=pv.get_makes("tesla",2020)# getting makes for manufacturer ID and model yearmakes_3=pv.get_makes(988,2005)# getting makes by vehicle_type searchmakes_4=pv.get_makes(vehicle_type="car")# displaying makesmakes_3make_idmake_namemanufacturer474-HONDA OF AMERICA MFG., INC.474HONDAHONDA OF AMERICA MFG., INC.475-HONDA OF AMERICA MFG., INC.475ACURAHONDA OF AMERICA MFG., INC.Accessing Each Make# Iterating through makesforminmakes_3:display(m)# Indexing makesfirst=makes_3[0]last=makes_3[len(makes_3)-1]# Getting Key Attributesprint(first.make_id)print(first.make_name)print(first.manufacturer)print(first.vehicle_type)make_idmake_namemanufacturer474-HONDA OF AMERICA MFG., INC.474HONDAHONDA OF AMERICA MFG., INC.make_idmake_namemanufacturer475-HONDA OF AMERICA MFG., INC.475ACURAHONDA OF AMERICA MFG., INC.474
HONDA
HONDA OF AMERICA MFG., INC.
NoneGetting JSON Resultsmakes_3.get_results()[{'MakeId': 474,
  'MakeName': 'HONDA',
  'MfrId': 988,
  'MfrName': 'HONDA OF AMERICA MFG., INC.'},
 {'MakeId': 475,
  'MakeName': 'ACURA',
  'MfrId': 988,
  'MfrName': 'HONDA OF AMERICA MFG., INC.'}]Getting DataFrame# Getting key attribute df dropping nanmakes_3.get_df()make_idmake_namemanufacturer474-HONDA OF AMERICA MFG., INC.474HONDAHONDA OF AMERICA MFG., INC.475-HONDA OF AMERICA MFG., INC.475ACURAHONDA OF AMERICA MFG., INC.# Getting full raw data df not dropping nanmakes_3.get_df(raw=True,drop_na=False)MakeIdMakeNameMfrIdMfrName474-HONDA OF AMERICA MFG., INC.474HONDA988HONDA OF AMERICA MFG., INC.475-HONDA OF AMERICA MFG., INC.475ACURA988HONDA OF AMERICA MFG., INC.Manufacturer MethodsGetting Manufacturerspvaw.get_manufacturers(m_type=None, page=1)Parameters: m_type:a str representing part or all of the manufacturer type (e.g. "Intermediate")page:int representing the api page number. Each page returns 100 manufacturersReturns:ResultsList object which stores a list of Manufacturer objects# getting manufacturers by api page numbermanufacturers=pv.get_manufacturers(page=5)# getting manufacturers by manufacturer typemanufacturers_2=pv.get_manufacturers(m_type="complete",page=1)Searching for Specific Manufacturerspvaw.get_manufacturer_details(manufacturer_name_or_id)Parameters: manufacturer_name_or_id:a str representing manufacturer name or an int representing the manufacturer IDReturns:ResultsList object which stores a list of Manufacturer objects matching the manufacturer search# getting manufacturer(s) from manufacturer name searchmanufacturers_3=pv.get_manufacturer_details("Toyota")# getting manufacturer from manufacturter idmanufacturers_4=pv.get_manufacturer_details(988)Accessing Each Manufacturer# Iterating through manufacturersforminmanufacturers[:4]:display(m)# Indexing manufacturersfirst=manufacturers[0]last=manufacturers[len(manufacturers)-1]# Getting Key Attributesprint(first.id)print(first.common_name)print(first.name)print(first.vehicle_types)namevehicle_typesid1387WOOPYONG MOTOR WHEEL LTD[]1387namevehicle_typesid1388WORCESTER TANK & EQUIPMENT CO., INC[]1388namevehicle_typesid1389WORCESTER WHITE AUTOCAR, INC.[]1389namevehicle_typesid1390WORKBENCH, INC.[Trailer]13901387
None
WOOPYONG MOTOR WHEEL LTD
[]Getting JSON Resultsmanufacturers.get_results()[{'Country': '',
  'Mfr_CommonName': None,
  'Mfr_ID': 1387,
  'Mfr_Name': 'WOOPYONG MOTOR WHEEL LTD',
  'VehicleTypes': []},
 {'Country': 'UNITED STATES (USA)',
  'Mfr_CommonName': None,
  'Mfr_ID': 1388,
  'Mfr_Name': 'WORCESTER TANK & EQUIPMENT CO., INC',
  'VehicleTypes': []},
 ...Getting DataFrame# Getting key attribute df dropping nanmanufacturers.get_df()namevehicle_typesid1387WOOPYONG MOTOR WHEEL LTD[]13871388WORCESTER TANK & EQUIPMENT CO., INC[]13881389WORCESTER WHITE AUTOCAR, INC.[]13891390WORKBENCH, INC.[Trailer]13901391U-SCREEN U.S.A., INC.[Trailer]1391............1479TAZZARI GL SPA[Low Speed Vehicle (LSV)]14791480CHANGZHOU CITY WENMING VEHICLE ACCESSORIES FAC...[]14801481SALSCO, INC.[Trailer]14811482LIFT N LOCK, LLC[]14821483CONTINENTAL BIOMASS INDUSTRIES, INC.[]148392 rows × 3 columns# Getting full raw data df not dropping nanmanufacturers.get_df(raw=True,drop_na=False)CountryMfr_CommonNameMfr_IDMfr_NameVehicleTypes1387NaNNone1387WOOPYONG MOTOR WHEEL LTD[]1388UNITED STATES (USA)None1388WORCESTER TANK & EQUIPMENT CO., INC[]1389UNITED STATES (USA)None1389WORCESTER WHITE AUTOCAR, INC.[]1390UNITED STATES (USA)None1390WORKBENCH, INC.[{'IsPrimary': False, 'Name': 'Trailer'}]1391UNITED STATES (USA)None1391U-SCREEN U.S.A., INC.[{'IsPrimary': False, 'Name': 'Trailer'}]..................1479ITALYNone1479TAZZARI GL SPA[{'IsPrimary': True, 'Name': 'Low Speed Vehicl...1480CHINANone1480CHANGZHOU CITY WENMING VEHICLE ACCESSORIES FAC...[]1481UNITED STATES (USA)None1481SALSCO, INC.[{'IsPrimary': True, 'Name': 'Trailer'}]1482UNITED STATES (USA)None1482LIFT N LOCK, LLC[]1483UNITED STATES (USA)None1483CONTINENTAL BIOMASS INDUSTRIES, INC.[]92 rows × 5 columns