The python scripts below are written with Python 3.7, but many of them will work with other versions of python. If you don't have python installed you can get it here.
In this example we will show how an insurance company or police department might use our API to search for specific vehicles that have been stolen and were never recovered. All that is needed is the Vehicle Identification Number (VIN) and the date the vehicle was stolen.
Our database is one of the largest in the industry with the listing and sales data of over 420M vehicles, so whenever a stolen car resurfaces on the open market we'll probably see it.
This example assumes you have already set up your environment as discussed on the API Quick Start Page and have retrieved your access token.
We will first take a list of VIN and date tuples that represent the stolen vehicles and the date they were stolen. We will then make a vehicle history request to our API with the VINs and check for any instances of the vehiclesentering the market after the date they were reported stolen. When we find one the insurance company or police will be able to go and recover the vehicle.
Example Code
#Here we do history lookups from a list of stolen vehicles
#for this example we will use a hard coded vehicle list
from cisapi import CisApi
api=CisApi()
tuples=[
("12345678912345678", "2020-01-01"),
("12345678922345679", "2019-10-31"),
("12345678932345670", "2017-06-06"),
("12345678942345671", "2018-08-20"),
("12345678952345672", "2019-04-19")
]
for tuple in tuples:
vin=tuple[0]
stolenDate=tuple[1]
#make get request to "/vehicleHistory" endpoint
saleResp=api.vehicleHistory(vin)
#print(saleResp)
historyData=saleResp["data"]
#loop through the vehicle's history and check for any
#entries after it was stolen
for entry in historyData:
start=entry["firstSeen"]
end=entry["lastSeen"]
if(end>=stolenDate or start>=stolenDate):
#we just helped recover a stolen car
print("STOLEN CAR DETECTED!")
print("VIN: "+vin)
print("Dealership: "+entry["dealerName"])
print("State: "+entry["state"])
print("zipCode: "+entry["zip"])
print("In: "+start)
print("Out: "+end)