VinLINK™ WEB HTTP, SOAP, XML Service

VinLINK Service designed for HTTP access can be utilized from any operating system, including UNIX (LINUX), MAC OS, MS Wind.

VinLINK Service designed for HTTP access can be utilized from any operating system, including UNIX (LINUX), MAC OS, MS Windows Operating System, MS Pocket PC. A developer can use simple HTTP technology to request and receive a decoded report with a standardized XML format. It can be integrated within any project and provides the functionality of a Vehicle Identification Number (VIN) decoder with VIN validation and verification, including enhanced equipment information.

It offers a Vin Decoder API, a programmatic interface that allows any internet-connected application to grab vehicle information data instantly and safely.

Please visit the following links for more information:

http://www.vinlink.com

Many people visit this website in a search to answer a question: How to decode a vin? Here is the answer. Actually we show you three answers using three different languages:

  • PHP
  • Python
  • Java

PHP – webmaster’s choice

VinLINK service is used in a lot of PHP based websites. Let us demonstrate a sample code that decodes basic YMM information from any VIN number.

Here we access VinLINK service using digest authentication. We fetch a report of type BASIC_LIGHT based on the $vin variable set earlier.

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, get_option('vd_user') . ":" . get_option('vd_password'));
curl_setopt($ch, CURLOPT_URL, "https://service.vinlink.com/report?type=BASIC_LIGHT&vin=" . $vin);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$report = curl_exec($ch);
curl_close($ch);

The report is stored in $report variable. Then we convert the report to XML form, so we can use xpath selector to locate the portion of the report containing our data. Next, we use the Model_Year, Make and Model attributes.

$xml = simplexml_load_string($report);
$decoded = $xml->xpath("REPORT/VINPOWER/VIN/DECODED");	
$year = (string)$decoded[0]['Model_Year'];
$make = (string)$decoded[0]['Make'];
$model = (string)$decoded[0]['Model'];

Jobs done! We can display the variables. But it’s just the beginning, VinLINK reports contain much more data.

Python – web, data processing and automation

Python is a scripting language that evolved into data processing and automation tool. It is also powering a lot of websites. Here is an example code using VinLINK Cloud API reports. Full code is available in github: https://github.com/Piotr3kK/vinlink-http-vin-decoder-python

First we start with necessary imports. We use python’s request, xml.etree packages and sys for command line arguments processing.

import sys
import requests
from requests.auth import HTTPDigestAuth
import xml.etree.ElementTree as ET

Then we just declare vinlink service entry URL prefix and process every VIN provided at the command line:

url = 'http://service.vinlink.com/report?type=BASIC_PLUS&vin='
for vin in sys.argv[1:]:
        results = requests.get(url+vin, auth=HTTPDigestAuth('login', 'password'))
        if results:
            tree = ET.fromstring(results.text)
            e = tree.findall('./REPORT/VINPOWER/VIN/DECODED/ITEM')
            for i in e:
                print('%s = %s' % (i.attrib['name'], i.attrib['value']))

This code is self explanatory. And it is based on an XML api. VinLINK is also accessible using SOAP webservice protocol. Here is an analogous code using python SOAP client using zeep library.

Imports first:

import sys
from zeep import Client
from zeep.wsse.username import UsernameToken

And here is the code. It is very similar to the solution above. The difference is that we get the report from the webservice structured, so we can use it as object:

client = Client('http://ws.vinlink.com/VLWS/services/Decoder?wsdl', wsse=UsernameToken('login', 'password'))
    for vin in sys.argv[1:]:
        results = client.service.decode(vin, 'BASIC_PLUS')
        if results:
            result = results[0]
            # print main attributes
            print("Model Year: %s" % result.modelYear)
            print("Make: %s" % result.make)
            print("Model: %s" % result.model)
            print("Trim Level: %s" % result.trimLevel)
            print("Engine Type: %s" % result.engineType)
            print("Body Type: %s" % result.bodyType)
            print("Drive Line Type: %s" % result.driveLineType)
            print("Transmission: %s" % result.transmission)
            # print all available attributes
            attributes = result.vinSpecification.Item
            for a in attributes:
                print("%s = %s" % (a.name, a.value))

Ful code for Python webservice is also in github: https://github.com/Piotr3kK/vinlink-vin-decoder-python.

Java – for enterprise solutions and web

Java for years was a language of choice for enterprise solutions. There are numerous tools built in Java from simple workflows used by car insurance agents to sophisticated business processes managed in bank environments. With the advent of Spring, it is frequently used for microservices and cloud applications.

Here is how we use Java to get a VinLINK report.

Java is very verbose language. What you could do in a single line of Python code, takes five or ten in Java. The reason for this is Java strong object foundation. Often instead of calling a function with some parameters, you need to create and configure an object to pass to another objects method. However this verbosity is not that painful when used with Dependency Injection frameworks like Spring. Spring does a lot of automation in creating, configuring and interweaving objects for us, and it simplifies the whole process.

Java Verbosity Explained

The code below is a simple example and it doesn’t use any DI framework to reduce it’s verbosity. In reality you could use Spring’s WebService Template to make it more managable. In imports we use jax-ws generated stub, that is built using maven based on WSDL provided by VinLINK WebService.

import java.util.List;

import com.vinlink.ws.*;

public class Client {

Then we create Decoder service stub and pass it a HandlerResolver (full code at github: https://github.com/Piotr3kK/vinlink-vin-decoder-java) that fills in authorization headers. Then we create communication port for connecting to the webservice.

public static void main(String[] args) {
		
		// create account at www.vinlink.com
		String LOGIN = "login";
		String PASSWD = "password";

		try {
			Decoder service = new Decoder();
			HeaderHandlerResolver handlerResolver = new HeaderHandlerResolver();
			handlerResolver.setUser(LOGIN);
			handlerResolver.setPasswd(PASSWD);
			service.setHandlerResolver(handlerResolver);
			DecoderPortType port = service.getDecoderHttpPort();

Then we just process every vin provided on the command line, catch eventual exceptions and close the code.

for (String vin: args) {
				ArrayOfReport reports = port.decode(vin, ReportTypes.BASIC_PLUS);
				List<Report> reprtList = reports.getReport();
				for (Report r : reprtList) {
					List<Item> items = r.getVinSpecification().getValue().getItem();
					for (Item i : items) {
						String n = i.getName().getValue();
						String v = i.getValue().getValue();
						System.out.printf("%s\t%s\n", n, v);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}