目前我所知道的车辆违章查询API接口较为常用的有两种:易源数据和聚合数据。这里我将介绍易源数据提供的免费全国车辆违章查询API接口及其使用方法。
易源数据提供的车辆违章查询API接口需要先进行注册并获取AppKey才能使用。注册地址为:https://www.showapi.com/auth/reg
获取AppKey后,就可以使用易源数据提供的车辆违章查询API接口了。API接口地址为:https://route.showapi.com/2427-1
请求方式:GET
请求参数说明:
| 参数名 | 必选 | 类型 | 说明 |
| --- | --- | --- | --- |
| showapi_appid | 是 | string | 易源数据提供的AppID |
| showapi_sign | 是 | string | 易源数据提供的签名 |
| carNo | 是 | string | 车牌号 |
| engineNo | 是 | string | 发动机号 |
| carType | 是 | string | 车辆类型(小型车:02,大型车:01) |
| prov | 是 | string | 省份简称(如:京,沪,津,渝等) |
返回参数说明:
| 参数名 | 类型 | 说明 |
| --- | --- | --- |
| showapi_res_code | int | 返回状态码(0:成功,其他:失败) |
| showapi_res_error | string | 错误信息 |
| showapi_res_body | object | 返回结果 |
返回结果示例:
```
{
"showapi_res_code": 0,
"showapi_res_error": "",
"showapi_res_body": {
"allNum": 3,
"allPages": 1,
"contentlist": [
{
"area": "北京市",
"date": "20180817",
"fen": 6,
"money": 200,
"handled": 0,
"hphm": "京A12345",
"hpzl": "02",
"jttab": "七环",
"wzcity": "010",
"wzdd": "康庄路",
"wzlx": "121",
"wztime": "2018-08-17 08:30:00",
"wzzt": "0"
},
{
"area": "北京市",
"date": "20180817",
"fen": 6,
"money": 200,
"handled": 0,
"hphm": "京A12345",
"hpzl": "02",
"jttab": "七环",
"wzcity": "010",
"wzdd": "康庄路",
"wzlx": "121",
"wztime": "2018-08-17 08:30:00",
"wzzt": "0"
},
{
"area": "北京市",
"date": "20180817",
"fen": 6,
"money": 200,
"handled": 0,
"hphm": "京A12345",
"hpzl": "02",
"jttab": "七环",
"wzcity": "010",
"wzdd": "康庄路",
"wzlx": "121",
"wztime": "2018-08-17 08:30:00",
"wzzt": "0"
}
],
"currentPage": 1,
"pageSize": 10
}
}
```
使用示例:
```
import requests
url = "https://route.showapi.com/2427-1"
app_id = "你的AppID"
app_secret = "你的AppSecret"
car_no = "京A12345"
engine_no = "123456"
car_type = "02"
prov = "京"
response = requests.get(url, params={
"showapi_appid": app_id,
"showapi_sign": app_secret,
"carNo": car_no,
"engineNo": engine_no,
"carType": car_type,
"prov": prov
})
result = response.json()
if result["showapi_res_code"] == 0:
print(result["showapi_res_body"]["contentlist"])
else:
print(result["showapi_res_error"])
```