一、什么是VIN码识别解析接口?
VIN码不仅是车辆的“身份证”,更是连接制造、销售、维修、保险、金融等多个环节的数字纽带。而VIN码查询API,正是打通这一链条的关键工具。
无论是汽车电商平台、二手车商、维修厂,还是保险公司、金融机构,都能通过接入该API实现信息自动化、决策智能化和服务标准化。
二、如何用C#进行调用?
下面我们以阿里云的接口为例,具体代码示例如下:
接口地址:https://market.aliyun.com/apimarket/detail/cmapi00065864
//using System.IO;
//using System.Text;
//using System.Net;
//using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;
private const String host = "https://tsvin.market.alicloudapi.com";
private const String path = "/vin/index";
private const String method = "GET";
private const String appcode = "你自己的AppCode";
static void Main(string[] args)
{
String querys = "vin=LSJA24U64MS039980";
String bodys = "";
String url = host + path;
HttpWebRequest httpRequest = null;
HttpWebResponse httpResponse = null;
if (0 < querys.Length)
{
url = url + "?" + querys;
}
if (host.Contains("https://"))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
}
else
{
httpRequest = (HttpWebRequest)WebRequest.Create(url);
}
httpRequest.Method = method;
httpRequest.Headers.Add("Authorization", "APPCODE " + appcode);
if (0 < bodys.Length)
{
byte[] data = Encoding.UTF8.GetBytes(bodys);
using (Stream stream = httpRequest.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
}
try
{
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
}
catch (WebException ex)
{
httpResponse = (HttpWebResponse)ex.Response;
}
Console.WriteLine(httpResponse.StatusCode);
Console.WriteLine(httpResponse.Method);
Console.WriteLine(httpResponse.Headers);
Stream st = httpResponse.GetResponseStream();
StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("\n");
}
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
返回结果如下:
{
"code": 1,
"msg": "操作成功",
"data": {
"vin": "LSJA24U64MS039980",
"matching_mode": 1,
"is_commercial": 0,
"is_import": 0,
"is_rules": 1,
"cid": "50147",
"brand_name": "荣威",
"manufacturer": "上汽集团",
"series_name": "荣威RX5",
"name": "2021款 PLUS 330TGI 自动国潮智臻版",
"year": "2021",
"img": "http://static.tanshuapi.com/car/202426/17215774571d2839.jpg",
"price": "13.08万",
"market_price": "13.08万",
"gearbox": "7挡湿式双离合",
"gearnum": "7",
"geartype": "湿式双离合变速箱(DCT)",
"engine_model": "15C4E",
"driven_type": "前置前驱",
"displacement_ml": "1490",
"displacement": "1.5",
"nedczhyh": "6.9",
"effluent_standard": "国VI",
"scale": "紧凑型SUV",
"csjg": "SUV",
"cms": "5",
"zws": "5",
"market_date": "2021.07",
"stop_date": "",
"length": "4571",
"width": "1855",
"high": "1719",
"wheelbase": "2708",
"trackfront": "1574",
"trackrear": "1593",
"full_weight": "1539",
"full_weight_max": "1972",
"full_weight_zz": "",
"front_tyre_size": "235/45 R19",
"rear_tyre_size": "235/45 R19",
"rlxs": "汽油",
"ryxh": "92号",
"gearbox_number": "",
"chassis_number": "",
"zdgl": "133",
"zdml": "181",
"front_brake_type": "通风盘式",
"rear_brake_type": "盘式",
"parking_brake_type": "电子驻车",
"qfs": "4",
"gyfs": "直喷",
"body_type": "承载式",
"version": "自动国潮智臻版",
"model_list": [
{
"cid": "50147",
"brand_name": "荣威",
"series_name": "荣威RX5",
"name": "2021款 PLUS 330TGI 自动国潮智臻版"
},
{
"cid": "50146",
"brand_name": "荣威",
"series_name": "荣威RX5",
"name": "2021款 PLUS 330TGI 自动国潮智享版"
},
{
"cid": "50154",
"brand_name": "荣威",
"series_name": "荣威RX5",
"name": "2021款 PLUS 300TGI 自动Ali国潮豪华荣麟版"
},
{
"cid": "50155",
"brand_name": "荣威",
"series_name": "荣威RX5",
"name": "2021款 PLUS 300TGI 自动Ali国潮旗舰荣麟版"
},
{
"cid": "50145",
"brand_name": "荣威",
"series_name": "荣威RX5",
"name": "2021款 PLUS 330TGI 手动国潮智享版"
},
{
"cid": "50151",
"brand_name": "荣威",
"series_name": "荣威RX5",
"name": "2020款 20T 自动4G互联百万款"
}
]
}
}