
车架号VIN
企业用户实名使用个人用户实名使用个人用户无法使用
传入17位车辆识别码(车架号)VIN码来获取车辆的品牌、车型年款、出厂日期、发动机类型、排量、车系等多维度车辆参数
价格
¥0元/20次
新用户免费体验,自购买起有效期1个月
选择套餐:

常见问题
VIN车架号查询API能查到什么?
输入17位车架号,返回品牌、车型、年款、排量、发动机型号、变速箱类型、机油信息、厂商指导价、车辆图片等几十项车辆参数。
支持哪些车型?
覆盖国内外主流乘用车品牌,包括国产和进口车型。
变速箱信息和机油信息是什么?
变速箱信息包括品牌、型号、加油量等;机油信息包括粘稠度、质量等级、参考用量等,适用于维修保养场景。
查不到记录会计费吗?
不计费。只有查询成功才会计费。
有免费试用吗?
新用户注册可免费试用20次。
返回的车辆图片可以用吗?
可以。返回的logo字段为车辆图片URL,可直接用于展示。
支持哪些开发语言?
提供Java、Python、PHP、C#四种语言的代码示例,可直接复制使用。
服务稳定吗?
服务安全稳定,毫秒级响应,支持高并发调用,7*24小时技术支持,专业级品质保证!
对接有问题怎么办?
可联系客服拉技术对接群。
接口名称:VIN车架号查询
描述:输入vin车架号,查询车辆信息
请求地址 url:https://api.shuxuntech.com/v1/vin/query
请求方式 method:get/post
参数:
| 名称 | 参数位置 | 类型 | 是否必填 | 说明 |
|---|---|---|---|---|
| appKey | head | string | 是 | 数勋分配appKey |
| timestamp | head | string | 是 | unix时间毫秒值 |
| sign | head | string | 是 | 签名,说明 |
| vin | query | string | 是 | 车架号 |
签名算法说明:
数勋分配的appKey、当前unix时间毫秒值timestamp、数勋分配的appSecret、 按顺序拼接sha256加密得到sign,查看如下示例
appKey = aaa;
timestamp = 1682476904289;
appSecret = bbb;
sign = sha256(appKey+timestamp+appSecret)
正确返回:
{
"code": "0",
"msg": "成功",
"isFee": 1,
"seqNo": "bc393r21lk7mz2i6rmgt5oyp33tbcks7",
"data": {
"result": 1,
"info": {
"gearboxinfo": { //变速箱信息
"gearboxbrand": "捷特科", //变速箱品牌
"joint": null, //接口型号
"gravityoil": "4L-5L", //重力加油量
"gearboxmodel": "RE0F10D/J***17E/JATCO", //变速箱型号
"mechanicaloil": "12L" //机械加油量
},
"logo": "https://img.shuxuntech.com/vin_logo/202402/1708504285067.png", //车辆图片
"fueltype": "汽油", //燃油类型
"frontbraketype": "通风盘式", //前制动类型
"comfuelconsumption": "8.4", //油耗
"enginemodel": "QR25", //发动机型号(参考)
"gearnum": "7", //档位数
"machineoil": { //机油信息
"volume": "4.6L", //参考用量
"viscosity": "0W-20", //粘稠度
"level": "SP", //质量等级
"grade": "全合成" //机油分类
},
"len": "4897", //长 mm
"maxhorsepower": "186", //最大马力(Ps)
"price": "27.13万", //厂商指导价
"parkingbraketype": "脚刹", //驻车制动类型
"vin": "LGBR4DE43***0247", //车架号
"displacement": "2.5L", //排量(L)
"brand": "日产", //品牌
"environmentalstandards": "国六", //排放标准
"rearbraketype": "通风盘式", //后制动类型
"height": "1691", //高 mm
"drivemode": "前置前驱", //驱动方式
"ratedloadweight": null, //额定载质量
"displacementml": "2488", //排量(mL)
"iscorrect": 1, //1 VIN符合规则 0 VIN不符合规则
"groupid": "3887", //车型组ID
"weight": "1700", //重量,kg
"chassis": null, //底盘
"version": "智联豪华", //版本
"groupname": "*** 2.5L(2015.08-)", //车型组名称
"yeartype": "2021", //年款
"sizetype": "中型SUV", //尺寸类型
"seatnum": "5", //座位数
"doornum": "5", //车门数
"wheelbase": "2830", //轴距
"name": "*** 2021款 2.5L 两驱 智联豪华版", //名称
"geartype": "无级变速(CVT)", //变速箱类型
"cylindernum": "4", //气缸数(个)
"bodystructure": "承载式", //车体结构
"fuelgrade": "92号", //燃油标号
"carid": 132868, //车ID 对应车型详情API中的ID
"manufacturer": "东风日产", //厂家名称
"fuelmethod": "多点电喷", //供油方式
"engine": "QR25", //发动机
"bodytype": "SUV", //车身型式
"gearbox": "CVT无级变速(模拟7挡)", //变速箱
"fronttiresize": "235/65 R18", //前轮胎尺寸
"maxpower": "124", //最大功率 KW
"isimport": 0, //是否是进口 0国产 1进口
"reartiresize": "235/65 R18", //后轮胎尺寸
"listdate": "2020-08-13", //上市日期
"width": "1908", //宽 mm
"carlist": [ //车型列表 可能的车型
{
"name": "*** 2021款 2.5L 两驱 智联豪华版",//名称
"typeid": 1985, //类型ID
"typename": "***", //类型名称
"carid": 132868 //车ID 对应车型API中的ID,
"manufacturer": "长沙***科技发展股份有限公司", //厂家名称
"enginemodel": "YCA07260N-60;YCA***45N-60;YCA0***0N-60;YCA07190N-60",//发动机型号(参考)
"doornum": "", //车门数
"len": "9220", //长 mm
"price": "79.5万", //厂商指导价
"geartype": "手动档", //变速箱类型
"width": "2500", //宽
"height": "3070" //高
}
],
"typename": "***", //车型名称 对应typeid
"marketprice": "22.13万" //市场价
}
}
}
错误返回:
{
"code": "1",
"msg": "参数错误",
"isFee": 0,
"seqNo": null,
"data": null
}
返回字段描述:
| 字段名 | 类型 | 描述 |
|---|---|---|
| code | string | 错误码 |
| msg | string | 错误描述 |
| isFee | int | 是否计费(1:计费,0:不计费) |
| seqNo | string | 调用流水号 |
| data | object | 返回数据 |
data对象说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| result | int | 查询结果,1:查询成功,2:无记录 |
| info | object | 车辆信息 |
info对象说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| gearboxinfo | object | 变速箱信息 |
| logo | string | 车辆图片 |
| fueltype | string | 燃油类型 |
| frontbraketype | string | 前制动类型 |
| comfuelconsumption | string | 油耗 |
| enginemodel | string | 发动机型号(参考) |
| gearnum | string | 档位数 |
| machineoil | object | 机油信息 |
| len | string | 长 mm |
| maxhorsepower | string | 最大马力(Ps) |
| price | string | 厂商指导价 |
| parkingbraketype | string | 驻车制动类型 |
| vin | string | 车架号 |
| displacement | string | 排量(L) |
| brand | string | 品牌 |
| environmentalstandards | string | 排放标准 |
| rearbraketype | string | 后制动类型 |
| height | string | 高 mm |
| drivemode | string | 驱动方式 |
| ratedloadweight | string | 额定载质量 |
| displacementml | string | 排量(mL) |
| iscorrect | string | 1 VIN符合规则 0 VIN不符合规则 |
| groupid | string | 车型组ID |
| weight | string | 重量,kg |
| chassis | string | 底盘 |
| version | string | 版本 |
| groupname | string | 车型组名称 |
| yeartype | string | 年款 |
| sizetype | string | 尺寸类型 |
| seatnum | string | 座位数 |
| doornum | string | 车门数 |
| wheelbase | string | 轴距 |
| name | string | 名称 |
| geartype | string | 变速箱类型 |
| cylindernum | string | 气缸数(个) |
| bodystructure | string | 车体结构 |
| fuelgrade | string | 燃油标号 |
| carid | string | 车ID 对应车型详情API中的ID |
| manufacturer | string | 厂家名称 |
| fuelmethod | string | 供油方式 |
| engine | string | 发动机 |
| bodytype | string | 车身型式 |
| gearbox | string | 变速箱 |
| fronttiresize | string | 前轮胎尺寸 |
| maxpower | string | 最大功率 KW |
| isimport | string | 是否是进口 0国产 1进口 |
| reartiresize | string | 后轮胎尺寸 |
| listdate | string | 上市日期 |
| width | string | 宽 mm |
| carlist | array | 车型列表 |
| typename | string | 车型名称 对应typeid |
| marketprice | string | 市场价 |
gearboxinfo变速箱信息说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| gearboxbrand | string | 变速箱品牌 |
| joint | string | 接口型号 |
| gravityoil | string | 重力加油量 |
| gearboxmodel | string | 变速箱型号 |
| mechanicaloil | string | 机械加油量 |
machineoil机油信息说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| volume | string | 参考用量 |
| viscosity | string | 粘稠度 |
| level | string | 质量等级 |
| grade | string | 机油分类 |
carlist车型信息说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| name | string | 名称 |
| typeid | string | 类型ID |
| typename | string | 类型名称 |
| carid | string | 车ID |
| manufacturer | string | 厂家名称 |
| enginemodel | string | 发动机型号(参考) |
| doornum | string | 车门数 |
| len | string | 长 mm |
| price | string | 厂商指导价 |
| geartype | string | 变速箱类型 |
| width | string | 宽 |
| height | string | 高 |
code错误码说明
| code | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 参数错误 |
| 2 | 无记录 |
| 3 | 第三方服务异常 |
| 4 | 签名错误 |
| 5 | 余额不足 |
| 6 | 调用频率超限 |
| 7 | 账号停用 |
| 8 | 接口已停用 |
| 9 | 联系服务商开通接口权限 |
| 10 | ip不在白名单 |
| 11 | 系统异常 |
| 12 | 实名状态错误 |
| 99 | 其他异常,具体返回为准 |
VIN车架号查询
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.MessageDigest;
/**
* VIN车架号查询 - Java 示例代码
* 接口地址:https://api.shuxuntech.com/v1/vin/query
*
* 说明:本示例只使用 JDK 原生 API(java.net / java.security),不依赖任何第三方 jar 包,
* 也不需要本项目的工具类,复制到本地即可编译运行:
* javac VinQueryDemo.java
* java VinQueryDemo
*/
public class VinQueryDemo {
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private static final String APP_KEY = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private static final String APP_SECRET = "您的appSecret";
/** 接口地址 */
private static final String API_URL = "https://api.shuxuntech.com/v1/vin/query";
/** 车架号 */
private static final String VIN = "";
public static void main(String[] args) throws Exception {
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
String timestamp = String.valueOf(System.currentTimeMillis());
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256,得到小写十六进制字符串
String sign = sha256Hex(APP_KEY + timestamp + APP_SECRET);
// 3、业务参数,拼到 url 的 query 里
String query = "vin=" + urlEncode(VIN);
String url = API_URL + (query.isEmpty() ? "" : "?" + query);
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("appKey", APP_KEY);
conn.setRequestProperty("timestamp", timestamp);
conn.setRequestProperty("sign", sign);
conn.setConnectTimeout(10000);
conn.setReadTimeout(20000);
int status = conn.getResponseCode();
// 5、读取返回内容:报错时读错误流,避免只拿到一个异常看不到原因
InputStream in = (status >= 200 && status < 300) ? conn.getInputStream() : conn.getErrorStream();
String result = readAll(in);
conn.disconnect();
System.out.println("HTTP状态码=" + status);
System.out.println("返回结果=" + result);
}
/**
* sha256 加密,返回小写十六进制字符串
* 服务端校验签名用的就是这个算法(小写十六进制)
*/
private static String sha256Hex(String content) throws Exception {
byte[] bytes = MessageDigest.getInstance("SHA-256").digest(content.getBytes("UTF-8"));
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
sb.append(Character.forDigit((b >> 4) & 0xF, 16));
sb.append(Character.forDigit(b & 0xF, 16));
}
return sb.toString();
}
/** url 编码,中文参数需要编码 */
private static String urlEncode(String value) throws Exception {
return URLEncoder.encode(value, "UTF-8");
}
/** 读取输入流内容 */
private static String readAll(InputStream in) throws Exception {
if (in == null) {
return "";
}
StringBuilder sb = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
try {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} finally {
reader.close();
}
return sb.toString();
}
}
# VIN车架号查询 - Python 示例代码
# 接口地址:https://api.shuxuntech.com/v1/vin/query
#
# 说明:只使用 Python 标准库(urllib / hashlib / time),不需要 pip 安装任何第三方包,
# 保存为 vin_query_demo.py 后直接执行 python vin_query_demo.py 即可。
import hashlib
import time
import urllib.error
import urllib.parse
import urllib.request
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY = "您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET = "您的appSecret"
# 接口地址
API_URL = "https://api.shuxuntech.com/v1/vin/query"
# 车架号
VIN = ""
def sha256_hex(content):
"""sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法"""
return hashlib.sha256(content.encode("utf-8")).hexdigest()
def main():
# 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
timestamp = str(int(time.time() * 1000))
# 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
sign = sha256_hex(APP_KEY + timestamp + APP_SECRET)
# 3、业务参数
params = {}
params["vin"] = VIN
data = urllib.parse.urlencode(params)
# 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
request = urllib.request.Request(API_URL + ("?" + data if data else ""), method="GET")
request.add_header("appKey", APP_KEY)
request.add_header("timestamp", timestamp)
request.add_header("sign", sign)
# 5、读取返回内容:报错时也把返回体读出来,避免只拿到一个异常看不到原因
try:
with urllib.request.urlopen(request, timeout=20) as response:
status = response.getcode()
body = response.read().decode("utf-8")
except urllib.error.HTTPError as e:
status = e.code
body = e.read().decode("utf-8")
print("HTTP状态码=" + str(status))
print("返回结果=" + body)
if __name__ == "__main__":
main()
<?php
/**
* VIN车架号查询 - PHP 示例代码
* 接口地址:https://api.shuxuntech.com/v1/vin/query
*
* 说明:只使用 PHP 内置函数,不需要 composer 安装任何依赖,也不需要 curl 扩展,
* 保存为 vin_query_demo.php 后直接执行 php vin_query_demo.php 即可。
*/
// 数勋分配的 appKey,请替换为您自己的 appKey
$appKey = "您的appKey";
// 数勋分配的 appSecret,请替换为您自己的 appSecret
$appSecret = "您的appSecret";
// 接口地址
$url = "https://api.shuxuntech.com/v1/vin/query";
// 车架号
$vin = "";
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
$timestamp = sprintf('%.0f', microtime(true) * 1000);
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
$sign = hash('sha256', $appKey . $timestamp . $appSecret);
// 3、业务参数
$params = array(
'vin' => $vin,
);
$body = http_build_query($params);
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
$context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'header' => "appKey: {$appKey}\r\n"
. "timestamp: {$timestamp}\r\n"
. "sign: {$sign}\r\n",
'timeout' => 20,
// 返回 4xx、5xx 时也把返回体读出来,方便排查
'ignore_errors' => true,
),
));
$requestUrl = ($body === '') ? $url : $url . '?' . $body;
$result = file_get_contents($requestUrl, false, $context);
// 打印结果
if (!empty($http_response_header[0])) {
echo "HTTP状态=" . $http_response_header[0] . PHP_EOL;
}
echo "返回结果=" . $result . PHP_EOL;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
/**
* VIN车架号查询 - C# 示例代码
* 接口地址:https://api.shuxuntech.com/v1/vin/query
*
* 说明:只使用 .NET 基础类库(System.Net.Http / System.Security.Cryptography),不依赖任何第三方包。
* 需要 .NET Framework 4.5 及以上,或 .NET Core / .NET 5 及以上;
* 保存为 VinQueryDemo.cs 后,用 dotnet run 或 VS 控制台项目直接运行即可。
*/
public class VinQueryDemo
{
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private const string AppKey = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private const string AppSecret = "您的appSecret";
/** 接口地址 */
private const string ApiUrl = "https://api.shuxuntech.com/v1/vin/query";
/** 车架号 */
private const string Vin = "";
public static void Main(string[] args)
{
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
long millis = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
string timestamp = millis.ToString();
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
string sign = Sha256Hex(AppKey + timestamp + AppSecret);
// 3、业务参数
Dictionary<string, string> form = new Dictionary<string, string>();
form.Add("vin", Vin);
string body = ToFormBody(form);
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
using (HttpClient client = new HttpClient())
{
client.Timeout = TimeSpan.FromSeconds(20);
client.DefaultRequestHeaders.Add("appKey", AppKey);
client.DefaultRequestHeaders.Add("timestamp", timestamp);
client.DefaultRequestHeaders.Add("sign", sign);
string url = (body == "") ? ApiUrl : ApiUrl + "?" + body;
HttpResponseMessage response = client.GetAsync(url).GetAwaiter().GetResult();
// 5、读取返回内容,4xx、5xx 时 HttpClient 不会抛异常,这里同样能拿到返回体
string content = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
Console.WriteLine("HTTP状态码=" + (int)response.StatusCode);
Console.WriteLine("返回结果=" + content);
}
}
/** 拼装 application/x-www-form-urlencoded 内容,中文参数需要编码 */
private static string ToFormBody(Dictionary<string, string> form)
{
StringBuilder sb = new StringBuilder();
foreach (KeyValuePair<string, string> item in form)
{
if (sb.Length > 0)
{
sb.Append("&");
}
sb.Append(Uri.EscapeDataString(item.Key)).Append("=").Append(Uri.EscapeDataString(item.Value));
}
return sb.ToString();
}
/** sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法 */
private static string Sha256Hex(string content)
{
using (SHA256 sha256 = SHA256.Create())
{
byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(content));
StringBuilder sb = new StringBuilder(bytes.Length * 2);
foreach (byte b in bytes)
{
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
}
}
// VIN车架号查询 - Node.js 示例代码
// 接口地址:https://api.shuxuntech.com/v1/vin/query
//
// 说明:只使用 Node.js 内置模块(https / crypto),不需要 npm 安装任何第三方包,
// 保存为 vin_query_demo.js 后直接执行 node vin_query_demo.js 即可(需 Node 10 及以上)。
const https = require('https');
const crypto = require('crypto');
// 数勋分配的 appKey,请替换为您自己的 appKey
const APP_KEY = '您的appKey';
// 数勋分配的 appSecret,请替换为您自己的 appSecret
const APP_SECRET = '您的appSecret';
// 接口地址
const API_URL = 'https://api.shuxuntech.com/v1/vin/query';
// 车架号
const VIN = '';
// sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法
function sha256Hex(content) {
return crypto.createHash('sha256').update(content, 'utf8').digest('hex');
}
// 打印返回结果
function printResult(statusCode, body) {
console.log('HTTP状态码=' + statusCode);
console.log('返回结果=' + body);
}
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
const timestamp = String(Date.now());
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
const sign = sha256Hex(APP_KEY + timestamp + APP_SECRET);
// 3、业务参数,放在 url 的 query 里(中文由 URLSearchParams 自动 URL 编码)
const query = new URLSearchParams({ vin: VIN }).toString();
const url = query ? API_URL + '?' + query : API_URL;
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
const request = https.request(url, {
method: 'GET',
headers: {
appKey: APP_KEY,
timestamp: timestamp,
sign: sign
},
timeout: 20000
}, function (response) {
// 5、读取返回内容:即使报错(4xx、5xx)也能拿到返回体,避免只看到异常看不到原因
let body = '';
response.setEncoding('utf8');
response.on('data', function (chunk) { body += chunk; });
response.on('end', function () { printResult(response.statusCode, body); });
});
request.on('timeout', function () {
request.destroy();
console.log('请求超时');
});
request.on('error', function (err) {
console.log('请求异常=' + err.message);
});
request.end();
// VIN车架号查询 - Go 示例代码
// 接口地址:https://api.shuxuntech.com/v1/vin/query
//
// 说明:只使用 Go 标准库(net/http、crypto/sha256、encoding/hex 等),不需要引入任何第三方包,
// 保存为 vin_query_demo.go 后直接执行 go run vin_query_demo.go 即可。
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"net/http"
"net/url"
"time"
)
// 数勋分配的 appKey,请替换为您自己的 appKey
const appKey = "您的appKey"
// 数勋分配的 appSecret,请替换为您自己的 appSecret
const appSecret = "您的appSecret"
// 接口地址
const apiURL = "https://api.shuxuntech.com/v1/vin/query"
// 车架号
const vin = ""
// sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法
func sha256Hex(content string) string {
sum := sha256.Sum256([]byte(content))
return hex.EncodeToString(sum[:])
}
func main() {
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
timestamp := fmt.Sprintf("%d", time.Now().UnixNano()/int64(time.Millisecond))
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
sign := sha256Hex(appKey + timestamp + appSecret)
// 3、业务参数,放在 url 的 query 里(url.Values 会自动对中文做 URL 编码)
query := url.Values{}
query.Set("vin", vin)
requestURL := apiURL
if len(query) > 0 {
requestURL = apiURL + "?" + query.Encode()
}
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
req, err := http.NewRequest("GET", requestURL, nil)
if err != nil {
fmt.Println("创建请求失败=" + err.Error())
return
}
req.Header.Set("appKey", appKey)
req.Header.Set("timestamp", timestamp)
req.Header.Set("sign", sign)
client := &http.Client{Timeout: 20 * time.Second}
resp, err := client.Do(req)
if err != nil {
fmt.Println("请求异常=" + err.Error())
return
}
defer resp.Body.Close()
// 5、读取返回内容:即使报错(4xx、5xx)也能拿到返回体
body, _ := io.ReadAll(resp.Body)
fmt.Println("HTTP状态码=" + resp.Status)
fmt.Println("返回结果=" + string(body))
}
#!/usr/bin/env bash
# VIN车架号查询 - curl 示例代码
# 接口地址:https://api.shuxuntech.com/v1/vin/query
#
# 说明:只依赖系统自带的 curl 和 openssl(用于计算 sha256),不需要安装任何第三方工具,
# 保存为 vin_query_demo.sh 后直接执行 bash vin_query_demo.sh 即可。
# 如果系统没有 openssl,可把下面 SIGN 那一行换成注释里的 sha256sum 写法。
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY="您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET="您的appSecret"
# 接口地址
API_URL="https://api.shuxuntech.com/v1/vin/query"
# 车架号
VIN=""
# 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
TIMESTAMP=$(($(date +%s) * 1000))
# 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256,得到小写十六进制字符串
# 没有 openssl 时可用: SIGN=$(printf '%s' "${APP_KEY}${TIMESTAMP}${APP_SECRET}" | sha256sum | awk '{print $1}')
SIGN=$(printf '%s' "${APP_KEY}${TIMESTAMP}${APP_SECRET}" | openssl dgst -sha256 | awk '{print $NF}')
# 3、业务参数放在 url 的 query 里(--data-urlencode 会自动对中文做 URL 编码)
# 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
# 5、-w 参数在返回内容后打印 HTTP 状态码,便于查看结果
curl -sS -G "${API_URL}" \
-H "appKey: ${APP_KEY}" \
-H "timestamp: ${TIMESTAMP}" \
-H "sign: ${SIGN}" \
--data-urlencode "vin=${VIN}" \
-w "\nHTTP状态码=%{http_code}\n"
java
python
php
c#
nodejs
go
curl
产品详情
API文档
示例代码
产品价格






