Spaces:
No application file
No application file
Commit ·
22c3eb1
1
Parent(s): 3792e80
added api call
Browse files- nhtsa_api_call.py +25 -0
nhtsa_api_call.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
def get_vehicle_info(vin,year):
|
| 4 |
+
url = f'https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVin/{vin}?format=json&modelyear={year}'
|
| 5 |
+
response = requests.get(url);
|
| 6 |
+
data = response.json()
|
| 7 |
+
|
| 8 |
+
for item in data["Results"]:
|
| 9 |
+
if item["Variable"] in ["Model Year"]:
|
| 10 |
+
year = item["Value"]
|
| 11 |
+
if item["Variable"] in ["Make"]:
|
| 12 |
+
make = item["Value"]
|
| 13 |
+
if item["Variable"] in ["Model"]:
|
| 14 |
+
model = item["Value"]
|
| 15 |
+
# year =
|
| 16 |
+
# make =
|
| 17 |
+
# model =
|
| 18 |
+
print(year)
|
| 19 |
+
print(make)
|
| 20 |
+
print(model)
|
| 21 |
+
return year, make, model
|
| 22 |
+
|
| 23 |
+
vin_num = input("What is vin number")
|
| 24 |
+
|
| 25 |
+
get_vehicle_info(vin_num)
|