
车型大全
企业用户实名使用个人用户实名使用个人用户无法使用
首先加载所有车品牌,根据车品牌查车系,根据车系查车型,根据车型查车辆详情信息
价格
¥0元/10次
新用户免费体验,自购买起有效期1个月
选择套餐:

接口名称:车品牌查询
描述:查询所有车辆品牌
请求地址 url:https://api.shuxuntech.com/v1/car_brand/query
请求方式 method:get/post
参数:
| 名称 | 参数位置 | 类型 | 是否必填 | 说明 |
|---|---|---|---|---|
| appKey | head | string | 是 | 数勋分配appKey |
| timestamp | head | string | 是 | 当前时间的毫秒数 |
| sign | head | string | 是 | 签名,说明 |
签名算法说明:
数勋分配的appKey、当前unix时间毫秒数timestamp、数勋分配的appSecret、 按顺序拼接sha256加密得到sign,查看如下示例
appKey = aaa;
timestamp = 1682476904289;
appSecret = bbb;
sign = sha256(appKey+timestamp+appSecret)
正确返回:
{
"code": "0",
"msg": "成功",
"isFee": 1,
"seqNo": "5m25xyvkvrasa17kgkwag2cofhj864rj",
"data": [
{
"initial": "A", //品牌首字母
"name": "ASKA", //品牌名称
"logo": "http://dev.img.shuxuntech.com/car_brand/202412/1734094124710.png", //品牌logo
"id": "167417" //品牌ID,可根据该ID查车系信息
}
]
}
错误返回:
{
"code": "1",
"msg": "请输入合法的名字",
"isFee": 0,
"seqNo": null,
"data": null
}
返回字段描述:
| 字段名 | 类型 | 描述 |
|---|---|---|
| code | string | 错误码 |
| msg | string | 错误描述 |
| isFee | int | 是否计费(1:计费,0:不计费) |
| seqNo | string | 调用流水号 |
| data | object | 返回数据 |
data对象说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| initial | string | 品牌首字母 |
| name | string | 品牌名称 |
| logo | string | 品牌logo |
| id | string | 品牌ID,根据该ID查车系信息 |
code错误码说明
| code | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 参数错误 |
| 2 | 无记录 |
| 3 | 第三方服务异常 |
| 4 | 签名错误 |
| 5 | 余额不足 |
| 6 | 调用频率超限 |
| 7 | 账号停用 |
| 8 | 接口已停用 |
| 9 | 联系服务商开通接口权限 |
| 10 | ip不在白名单 |
| 11 | 系统异常 |
| 12 | 实名状态错误 |
| 99 | 其他异常,具体返回为准 |
示例代码
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;
/**
* 车品牌查询 - Java 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_brand/query
*
* 说明:本示例只使用 JDK 原生 API(java.net / java.security),不依赖任何第三方 jar 包,
* 也不需要本项目的工具类,复制到本地即可编译运行:
* javac CarBrandQueryDemo.java
* java CarBrandQueryDemo
*/
public class CarBrandQueryDemo {
/** 数勋分配的 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/car_brand/query";
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、本接口没有业务参数
String query = "";
String url = API_URL;
// 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();
}
}
# 车品牌查询 - Python 示例代码
# 接口地址:https://api.shuxuntech.com/v1/car_brand/query
#
# 说明:只使用 Python 标准库(urllib / hashlib / time),不需要 pip 安装任何第三方包,
# 保存为 car_brand_query_demo.py 后直接执行 python car_brand_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/car_brand/query"
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 = {}
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
/**
* 车品牌查询 - PHP 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_brand/query
*
* 说明:只使用 PHP 内置函数,不需要 composer 安装任何依赖,也不需要 curl 扩展,
* 保存为 car_brand_query_demo.php 后直接执行 php car_brand_query_demo.php 即可。
*/
// 数勋分配的 appKey,请替换为您自己的 appKey
$appKey = "您的appKey";
// 数勋分配的 appSecret,请替换为您自己的 appSecret
$appSecret = "您的appSecret";
// 接口地址
$url = "https://api.shuxuntech.com/v1/car_brand/query";
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
$timestamp = sprintf('%.0f', microtime(true) * 1000);
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
$sign = hash('sha256', $appKey . $timestamp . $appSecret);
// 3、业务参数
$params = array(
);
$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;
/**
* 车品牌查询 - C# 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_brand/query
*
* 说明:只使用 .NET 基础类库(System.Net.Http / System.Security.Cryptography),不依赖任何第三方包。
* 需要 .NET Framework 4.5 及以上,或 .NET Core / .NET 5 及以上;
* 保存为 CarBrandQueryDemo.cs 后,用 dotnet run 或 VS 控制台项目直接运行即可。
*/
public class CarBrandQueryDemo
{
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private const string AppKey = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private const string AppSecret = "您的appSecret";
/** 接口地址 */
private const string ApiUrl = "https://api.shuxuntech.com/v1/car_brand/query";
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>();
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();
}
}
}
// 车品牌查询 - Node.js 示例代码
// 接口地址:https://api.shuxuntech.com/v1/car_brand/query
//
// 说明:只使用 Node.js 内置模块(https / crypto),不需要 npm 安装任何第三方包,
// 保存为 car_brand_query_demo.js 后直接执行 node car_brand_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/car_brand/query';
// 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、本接口没有业务参数
const url = 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();
// 车品牌查询 - Go 示例代码
// 接口地址:https://api.shuxuntech.com/v1/car_brand/query
//
// 说明:只使用 Go 标准库(net/http、crypto/sha256、encoding/hex 等),不需要引入任何第三方包,
// 保存为 car_brand_query_demo.go 后直接执行 go run car_brand_query_demo.go 即可。
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"net/http"
"time"
)
// 数勋分配的 appKey,请替换为您自己的 appKey
const appKey = "您的appKey"
// 数勋分配的 appSecret,请替换为您自己的 appSecret
const appSecret = "您的appSecret"
// 接口地址
const apiURL = "https://api.shuxuntech.com/v1/car_brand/query"
// 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、本接口没有业务参数
requestURL := apiURL
// 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
# 车品牌查询 - curl 示例代码
# 接口地址:https://api.shuxuntech.com/v1/car_brand/query
#
# 说明:只依赖系统自带的 curl 和 openssl(用于计算 sha256),不需要安装任何第三方工具,
# 保存为 car_brand_query_demo.sh 后直接执行 bash car_brand_query_demo.sh 即可。
# 如果系统没有 openssl,可把下面 SIGN 那一行换成注释里的 sha256sum 写法。
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY="您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET="您的appSecret"
# 接口地址
API_URL="https://api.shuxuntech.com/v1/car_brand/query"
# 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、本接口没有业务参数
# 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
# 5、-w 参数在返回内容后打印 HTTP 状态码,便于查看结果
curl -sS -G "${API_URL}" \
-H "appKey: ${APP_KEY}" \
-H "timestamp: ${TIMESTAMP}" \
-H "sign: ${SIGN}" \
-w "\nHTTP状态码=%{http_code}\n"
java
python
php
c#
nodejs
go
curl
接口名称:根据车品牌查车系
描述:输入车品牌ID,返回车系信息
请求地址 url:https://api.shuxuntech.com/v1/car_series/query
请求方式 method:get/post
参数:
| 名称 | 参数位置 | 类型 | 是否必填 | 说明 |
|---|---|---|---|---|
| appKey | head | string | 是 | 数勋分配appKey |
| timestamp | head | string | 是 | 当前时间的毫秒数 |
| sign | head | string | 是 | 签名,说明 |
| brandId | query | string | 是 | 车品牌ID |
签名算法说明:
数勋分配的appKey、当前unix时间毫秒数timestamp、数勋分配的appSecret、 按顺序拼接sha256加密得到sign,查看如下示例
appKey = aaa;
timestamp = 1682476904289;
appSecret = bbb;
sign = sha256(appKey+timestamp+appSecret)
正确返回:
{
"code": "0",
"msg": "成功",
"isFee": 1,
"seqNo": "zxn7vwtxriq56e16zkd3ehf1ggv230aw",
"data": [
{
"initial": "A", //品牌首字母
"name": "一汽奥迪", //子公司
"id": "219", //子公司ID
"list": [ // 子公司下车系列表
{
"name": "奥迪A3", //车系名称
"logo": "http://dev.img.shuxuntech.com/car_series/202412/1734096265662.png", //车系照片
"id": "220", //车系ID,根据该ID查车型
"fullName": "奥迪A3", //车系全称
"saleState": "在销" //销售状态
}
]
},
{
"initial": "A",
"name": "进口奥迪(进口)",
"id": "228",
"list": [
{
"name": "奥迪A1",
"logo": "http://dev.img.shuxuntech.com/car_series/202412/1734096285288.png",
"id": "229",
"fullName": "奥迪A1",
"saleState": "停销"
}
]
}
]
}
错误返回:
{
"code": "1",
"msg": "参数错误",
"isFee": 0,
"seqNo": null,
"data": null
}
返回字段描述:
| 字段名 | 类型 | 描述 |
|---|---|---|
| code | string | 错误码 |
| msg | string | 错误描述 |
| isFee | int | 是否计费(1:计费,0:不计费) |
| seqNo | string | 调用流水号 |
| data | array | 车品牌下子公司数组 |
data车品牌下子公司数组
| 字段名 | 类型 | 描述 |
|---|---|---|
| initial | string | 品牌首字母 |
| name | string | 子公司名称 |
| id | string | 子公司ID |
| list | array | 子公司下车系列表 |
list子公司下车系列表
| 字段名 | 类型 | 描述 |
|---|---|---|
| id | string | 车系ID,可根据该ID查车型 |
| name | string | 车系名称 |
| fullName | string | 车系全称 |
| saleState | string | 销售状态 |
| logo | string | 车系照片 |
code错误码说明
| code | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 参数错误 |
| 2 | 无记录 |
| 3 | 第三方服务异常 |
| 4 | 签名错误 |
| 5 | 余额不足 |
| 6 | 调用频率超限 |
| 7 | 账号停用 |
| 8 | 接口已停用 |
| 9 | 联系服务商开通接口权限 |
| 10 | ip不在白名单 |
| 11 | 系统异常 |
| 12 | 实名状态错误 |
| 99 | 其他异常,具体返回为准 |
示例代码
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;
/**
* 根据车品牌查车系 - Java 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_series/query
*
* 说明:本示例只使用 JDK 原生 API(java.net / java.security),不依赖任何第三方 jar 包,
* 也不需要本项目的工具类,复制到本地即可编译运行:
* javac CarSeriesQueryDemo.java
* java CarSeriesQueryDemo
*/
public class CarSeriesQueryDemo {
/** 数勋分配的 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/car_series/query";
/** 车品牌id */
private static final String BRAND_ID = "";
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 = "brandId=" + urlEncode(BRAND_ID);
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();
}
}
# 根据车品牌查车系 - Python 示例代码
# 接口地址:https://api.shuxuntech.com/v1/car_series/query
#
# 说明:只使用 Python 标准库(urllib / hashlib / time),不需要 pip 安装任何第三方包,
# 保存为 car_series_query_demo.py 后直接执行 python car_series_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/car_series/query"
# 车品牌id
BRAND_ID = ""
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["brandId"] = BRAND_ID
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
/**
* 根据车品牌查车系 - PHP 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_series/query
*
* 说明:只使用 PHP 内置函数,不需要 composer 安装任何依赖,也不需要 curl 扩展,
* 保存为 car_series_query_demo.php 后直接执行 php car_series_query_demo.php 即可。
*/
// 数勋分配的 appKey,请替换为您自己的 appKey
$appKey = "您的appKey";
// 数勋分配的 appSecret,请替换为您自己的 appSecret
$appSecret = "您的appSecret";
// 接口地址
$url = "https://api.shuxuntech.com/v1/car_series/query";
// 车品牌id
$brandId = "";
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
$timestamp = sprintf('%.0f', microtime(true) * 1000);
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
$sign = hash('sha256', $appKey . $timestamp . $appSecret);
// 3、业务参数
$params = array(
'brandId' => $brandId,
);
$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;
/**
* 根据车品牌查车系 - C# 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_series/query
*
* 说明:只使用 .NET 基础类库(System.Net.Http / System.Security.Cryptography),不依赖任何第三方包。
* 需要 .NET Framework 4.5 及以上,或 .NET Core / .NET 5 及以上;
* 保存为 CarSeriesQueryDemo.cs 后,用 dotnet run 或 VS 控制台项目直接运行即可。
*/
public class CarSeriesQueryDemo
{
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private const string AppKey = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private const string AppSecret = "您的appSecret";
/** 接口地址 */
private const string ApiUrl = "https://api.shuxuntech.com/v1/car_series/query";
/** 车品牌id */
private const string BrandId = "";
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("brandId", BrandId);
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();
}
}
}
// 根据车品牌查车系 - Node.js 示例代码
// 接口地址:https://api.shuxuntech.com/v1/car_series/query
//
// 说明:只使用 Node.js 内置模块(https / crypto),不需要 npm 安装任何第三方包,
// 保存为 car_series_query_demo.js 后直接执行 node car_series_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/car_series/query';
// 车品牌id
const BRAND_ID = '';
// 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({ brandId: BRAND_ID }).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();
// 根据车品牌查车系 - Go 示例代码
// 接口地址:https://api.shuxuntech.com/v1/car_series/query
//
// 说明:只使用 Go 标准库(net/http、crypto/sha256、encoding/hex 等),不需要引入任何第三方包,
// 保存为 car_series_query_demo.go 后直接执行 go run car_series_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/car_series/query"
// 车品牌id
const brandId = ""
// 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("brandId", brandId)
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
# 根据车品牌查车系 - curl 示例代码
# 接口地址:https://api.shuxuntech.com/v1/car_series/query
#
# 说明:只依赖系统自带的 curl 和 openssl(用于计算 sha256),不需要安装任何第三方工具,
# 保存为 car_series_query_demo.sh 后直接执行 bash car_series_query_demo.sh 即可。
# 如果系统没有 openssl,可把下面 SIGN 那一行换成注释里的 sha256sum 写法。
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY="您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET="您的appSecret"
# 接口地址
API_URL="https://api.shuxuntech.com/v1/car_series/query"
# 车品牌id
BRAND_ID=""
# 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 "brandId=${BRAND_ID}" \
-w "\nHTTP状态码=%{http_code}\n"
java
python
php
c#
nodejs
go
curl
接口名称:根据车系查车型
描述:输入车系ID,查询车型信息
请求地址 url:https://api.shuxuntech.com/v1/car_type/query
请求方式 method:get/post
参数:
| 名称 | 参数位置 | 类型 | 是否必填 | 说明 |
|---|---|---|---|---|
| appKey | head | string | 是 | 数勋分配appKey |
| timestamp | head | string | 是 | unix时间毫秒值 |
| sign | head | string | 是 | 签名,说明 |
| seriesId | query | string | 是 | 车系ID |
| sort | query | string | 否 | 排序,默认不排序; year按年份、 yearr按年份逆序,productionstate按生产状态、 productionstater按生产状态逆序 |
签名算法说明:
数勋分配的appKey、当前unix时间毫秒值timestamp、数勋分配的appSecret、 按顺序拼接sha256加密得到sign,查看如下示例
appKey = aaa;
timestamp = 1682476904289;
appSecret = bbb;
sign = sha256(appKey+timestamp+appSecret)
正面返回:
{
"code": "0",
"msg": "成功",
"isFee": 1,
"seqNo": "b5y4kra9c5sdsy2xknnm1988qjwq2ccu",
"data": [
{
"initial": "A", //品牌首字母
"name": "奥迪A3",//车系名称
"id": "220", //车系ID
"list": [
{
"id": "2571", //车型ID,可根据该ID查车辆详情
"productionState": "停产", //生产状态
"listDate": "2016-04-06",// 上市年月
"yearType": "2016", //年款
"sizeType": "紧凑型车", //尺寸类型
"price": "18.49万", //价格
"name": "2016款 Sportback 35TFSI 进取型", //车型名称
"gearType": "双离合(DCT)", //变速箱类型
"logo": "http://dev.img.shuxuntech.com/car_type/202412/1734140910877.png", //车型图片
"displacement": "1.4T", //排量
"saleState": "停销" // 销售状态
},
{
"productionState": "停产",
"listDate": "2015-01-30",
"yearType": "2015",
"sizeType": "紧凑型车",
"price": "18.49万",
"name": "2015款 Sportback 35TFSI 手动 进取型",
"gearType": "手动(MT)",
"logo": "http://dev.img.shuxuntech.com/car_type/202412/1734140910877.png",
"displacement": "1.4T",
"id": "2577",
"saleState": "停销"
},
...
]
}
]
}
错误返回:
{
"code": "1",
"msg": "参数错误",
"isFee": 0,
"seqNo": null,
"data": null
}
返回字段描述:
| 字段名 | 类型 | 描述 |
|---|---|---|
| code | string | 错误码 |
| msg | string | 错误描述 |
| isFee | int | 是否计费(1:计费,0:不计费) |
| seqNo | string | 调用流水号 |
| data | object | 返回数据 |
data对象说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| initial | string | 品牌首字母 |
| name | string | 车系名称 |
| id | string | 车系ID |
| list | array | 车型信息数组 |
list车型信息数组
| 字段名 | 类型 | 描述 |
|---|---|---|
| id | string | 车型ID,可根据该ID查车辆详情 |
| name | string | 车型名称 |
| productionState | string | 生产状态 |
| saleState | string | 销售状态 |
| listDate | string | 上市年月 |
| yearType | string | 年款 |
| sizeType | string | 尺寸类型 |
| gearType | string | 变速箱类型 |
| displacement | string | 排量 |
| logo | string | 车型照片 |
| price | string | 价格 |
code错误码说明
| code | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 参数错误 |
| 2 | 无记录 |
| 3 | 第三方服务异常 |
| 4 | 签名错误 |
| 5 | 余额不足 |
| 6 | 调用频率超限 |
| 7 | 账号停用 |
| 8 | 接口已停用 |
| 9 | 联系服务商开通接口权限 |
| 10 | ip不在白名单 |
| 11 | 系统异常 |
| 12 | 实名状态错误 |
| 99 | 其他异常,具体返回为准 |
示例代码
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;
/**
* 根据车系查车型 - Java 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_type/query
*
* 说明:本示例只使用 JDK 原生 API(java.net / java.security),不依赖任何第三方 jar 包,
* 也不需要本项目的工具类,复制到本地即可编译运行:
* javac CarTypeQueryDemo.java
* java CarTypeQueryDemo
*/
public class CarTypeQueryDemo {
/** 数勋分配的 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/car_type/query";
/** 车系id */
private static final String SERIES_ID = "";
/** 排序方式 */
private static final String SORT = "";
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 = "seriesId=" + urlEncode(SERIES_ID) + "&" + "sort=" + urlEncode(SORT);
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();
}
}
# 根据车系查车型 - Python 示例代码
# 接口地址:https://api.shuxuntech.com/v1/car_type/query
#
# 说明:只使用 Python 标准库(urllib / hashlib / time),不需要 pip 安装任何第三方包,
# 保存为 car_type_query_demo.py 后直接执行 python car_type_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/car_type/query"
# 车系id
SERIES_ID = ""
# 排序方式
SORT = ""
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["seriesId"] = SERIES_ID
params["sort"] = SORT
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
/**
* 根据车系查车型 - PHP 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_type/query
*
* 说明:只使用 PHP 内置函数,不需要 composer 安装任何依赖,也不需要 curl 扩展,
* 保存为 car_type_query_demo.php 后直接执行 php car_type_query_demo.php 即可。
*/
// 数勋分配的 appKey,请替换为您自己的 appKey
$appKey = "您的appKey";
// 数勋分配的 appSecret,请替换为您自己的 appSecret
$appSecret = "您的appSecret";
// 接口地址
$url = "https://api.shuxuntech.com/v1/car_type/query";
// 车系id
$seriesId = "";
// 排序方式
$sort = "";
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
$timestamp = sprintf('%.0f', microtime(true) * 1000);
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
$sign = hash('sha256', $appKey . $timestamp . $appSecret);
// 3、业务参数
$params = array(
'seriesId' => $seriesId,
'sort' => $sort,
);
$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;
/**
* 根据车系查车型 - C# 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_type/query
*
* 说明:只使用 .NET 基础类库(System.Net.Http / System.Security.Cryptography),不依赖任何第三方包。
* 需要 .NET Framework 4.5 及以上,或 .NET Core / .NET 5 及以上;
* 保存为 CarTypeQueryDemo.cs 后,用 dotnet run 或 VS 控制台项目直接运行即可。
*/
public class CarTypeQueryDemo
{
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private const string AppKey = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private const string AppSecret = "您的appSecret";
/** 接口地址 */
private const string ApiUrl = "https://api.shuxuntech.com/v1/car_type/query";
/** 车系id */
private const string SeriesId = "";
/** 排序方式 */
private const string Sort = "";
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("seriesId", SeriesId);
form.Add("sort", Sort);
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();
}
}
}
// 根据车系查车型 - Node.js 示例代码
// 接口地址:https://api.shuxuntech.com/v1/car_type/query
//
// 说明:只使用 Node.js 内置模块(https / crypto),不需要 npm 安装任何第三方包,
// 保存为 car_type_query_demo.js 后直接执行 node car_type_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/car_type/query';
// 车系id
const SERIES_ID = '';
// 排序方式
const SORT = '';
// 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({ seriesId: SERIES_ID, sort: SORT }).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();
// 根据车系查车型 - Go 示例代码
// 接口地址:https://api.shuxuntech.com/v1/car_type/query
//
// 说明:只使用 Go 标准库(net/http、crypto/sha256、encoding/hex 等),不需要引入任何第三方包,
// 保存为 car_type_query_demo.go 后直接执行 go run car_type_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/car_type/query"
// 车系id
const seriesId = ""
// 排序方式
const sort = ""
// 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("seriesId", seriesId)
query.Set("sort", sort)
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
# 根据车系查车型 - curl 示例代码
# 接口地址:https://api.shuxuntech.com/v1/car_type/query
#
# 说明:只依赖系统自带的 curl 和 openssl(用于计算 sha256),不需要安装任何第三方工具,
# 保存为 car_type_query_demo.sh 后直接执行 bash car_type_query_demo.sh 即可。
# 如果系统没有 openssl,可把下面 SIGN 那一行换成注释里的 sha256sum 写法。
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY="您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET="您的appSecret"
# 接口地址
API_URL="https://api.shuxuntech.com/v1/car_type/query"
# 车系id
SERIES_ID=""
# 排序方式
SORT=""
# 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 "seriesId=${SERIES_ID}" \
--data-urlencode "sort=${SORT}" \
-w "\nHTTP状态码=%{http_code}\n"
java
python
php
c#
nodejs
go
curl
接口名称:根据车型查车辆详情
描述:输入carid,返回车辆详情
请求地址 url:https://api.shuxuntech.com/v1/car_detail/query
请求方式 method:post
参数:
| 名称 | 参数位置 | 类型 | 是否必填 | 说明 |
|---|---|---|---|---|
| appKey | head | string | 是 | 数勋分配appKey |
| timestamp | head | string | 是 | unix时间毫秒值 |
| sign | head | string | 是 | 签名,说明 |
| carid | query | string | 是 | 车辆ID |
签名算法说明:
数勋分配的appKey、当前unix时间毫秒值timestamp、数勋分配的appSecret、 按顺序拼接sha256加密得到sign,查看如下示例
appKey = aaa;
timestamp = 1682476904289;
appSecret = bbb;
sign = sha256(appKey+timestamp+appSecret)
正面返回:
{
"code": "0",
"msg": "成功",
"isFee": 1,
"seqNo": "tpvo4l7il70zzayuyvf4yj38pwqbt7jm",
"data": {
"result": 1,
"info": {
"id": 2571,//车型ID
"name": "2016款 Sportback 35 TFSI 进取型", //名称
"parentname": "奥迪A3",//上级名称
"brandname": "奥迪",//品牌
"initial": "A",//首字母
"parentid": 220,//上级ID
"logo": "https://img.shuxuntech.com/vin_logo/202407/1722393364472.png",//LOGO
"price": "18.49万",//厂家指导价
"yeartype": "2016",//年款
"listdate": "2016.04",//上市年月
"productionstate": "停产",//生产状态
"salestate": "停销",//销售状态
"sizetype": "紧凑型车",//尺寸类型
"depth": 4,//深度 1品牌 2子公司 3车型 4具体车型
"displacement": "1.4T",//排量(L)
"displacement2": "1.4",//排量不带L
"gearnum": "7",//挡位个数
"geartype": "干式双离合变速箱(DCT)",//变速箱类型
"geartype2": 1,//变数箱类型 1自动 2手动
"seatnum": "5",//乘员人数(区间)(个)
"drivemode": "前置前驱",//驱动方式
"drivemode2": 2,//驱动模式 2两驱 4驱 6驱 8驱
"environmentalstandards": "国IV(国V)",//环保标准
"environmentalstandards2": "5",//环保标准 数字型
"compartnum": 2,//车厢数
"groupid": "2762",//组名id(汽配接口用)
"groupname": "A3",//组名(汽配接口用)
"basic": {//基本参数
"price": "18.49万",//厂家指导价
"saleprice": "暂无报价",//商家报价
"warrantypolicy": "● 三年或10万公里",//保修政策
"vechiletax": "",//车船税减免
"displacement": "1.4T",//排量(L)
"gearbox": "7挡干式双离合",//变速箱
"gearnum": "7",//挡位个数
"geartype": "干式双离合变速箱(DCT)",//变速箱类型
"comfuelconsumption": "5.5",//综合工况油耗(L/100km)
"userfuelconsumption": "-",//网友油耗(L/100km)
"officialaccelerationtime100": "8.4",//官方0-100公里加速时间(s)
"testaccelerationtime100": "-",//实测0-100公里加速时间(s)
"maxspeed": "213",//最高车速(km/h)
"seatnum": "5",//乘员人数(区间)(个)
"mixfuelconsumption": "5.5",//混合工况油耗[L/100km]
"lowchargefuelconsumption": null,//最低荷电状态油耗[L/100km]
"electricfuelconsumption": null,//电能当量燃料消耗量[L/100km]
"nedcfuelconsumption": "5.5",//NEDC综合油耗[L/100km]
"firstownerwarrantypolicy": null //首任车主质保政策
},
"body": {//车身
"color": "#C7C8CA,水晶银|#F6F6F6,冰川白|#D37201,萨摩亚橙|#374A4A,季风灰|#D91624,米萨诺红|#482807,白鲸棕|#59222B,希纳兹红|#000000,深黑|#FFFFFF,阿玛菲白|#3F6383,海南蓝|#462807,钛金米|#5D6159,莲花灰",//车身颜色
"len": "4319",//车长(mm)
"width": "1785",//车宽(mm)
"height": "1426",//车高(mm)
"wheelbase": "2629",//轴距(mm)
"fronttrack": "-",//前轮距(mm)
"reartrack": "-",//后轮距(mm)
"weight": "1340",//整备质量(kg)
"fullweight": "",//满载质量(kg)
"mingroundclearance": "-",//最小离地间隙(mm)
"approachangle": "",//接近角(°)
"departureangle": "",//离去角(°)
"luggagevolume": "380-1220",//行李厢容积(L)
"luggagemode": "",//行李厢盖开合方式
"luggageopenmode": "无",//行李厢打开方式
"inductionluggage": "",//感应行李厢
"doornum": "5",//车门数(个)
"rooftype": "",//车顶型式
"hoodtype": "",//车篷型式
"roofluggagerack": "-",//车顶行李箱架
"sportpackage": "-",//运动外观套件
"totalweight": null,//总质量(kg)
"ratedloadweight": null,//额定载质量(kg)
"loadweightfactor": null,//载质量利用系数
"rampangle": null,//通过角[°]
"maxwadingdepth": null,//最大涉水深度[mm]
"minturndiameter": null,//最小转弯直径[m]
"electricluggage": "无",//电动行李厢
"bodytype": "两厢车",//车身型式
"fronttrunkvolume": null,//前备厢容积[L]
"dragcoefficient": null,//风阻系数[Cd]
"trunkpositionmemory": null//电动后备厢位置记忆
},
"engine": {//发动机
"position": "",//发动机位置
"model": "",//产品型号
"displacement": "1.4T",//排量(L)
"displacementml": "1395",//排量(mL)
"intakeform": "涡轮增压",//进气形式
"cylinderarrangetype": "L",//气缸排列型式
"cylindernum": "4",//气缸数(个)
"valvetrain": "4",//每缸气门数(个)
"valvestructure": "DOHC",//气门结构
"compressionratio": "-",//压缩比
"bore": "-",//缸径(mm)
"stroke": "-",//行程(mm)
"maxhorsepower": "150",//最大马力(Ps)
"maxpower": "110",//最大功率(kW)
"maxpowerspeed": "5000-6000",//最大功率转速(rpm)
"maxtorque": "250",//最大扭矩(Nm)
"maxtorquespeed": "1750-3000",//最大扭矩转速(rpm)
"fueltype": "汽油",//燃料类型
"fuelgrade": "95号",//燃油标号
"fuelmethod": "直喷",//供油方式
"fueltankcapacity": "50",//燃油箱容积(L)
"cylinderheadmaterial": "铝合金",//缸盖材料
"cylinderbodymaterial": "铝合金",//缸体材料
"environmentalstandards": "国IV(国V)",//环保标准
"startstopsystem": "●",//启停系统
},
"electricmotor": {//电动机
"frontmodel": null,//前电动机型号
"rearmodel": null,//后电动机型号
"frontbrand": null,//前电动机品牌
"rearbrand": null,//后电动机品牌
"motorpower": null,//电动机总功率[kW]
"motortorque": null,//电动机总扭矩[N.m]
"integratedpower": null,//系统综合功率[kW]
"integratedtorque": null,//系统综合扭矩[N.m]
"frontmaxpower": null,//前电动机最大功率[kW]
"frontmaxtorque": null,//前电动机最大扭矩[N.m]
"rearmaxpower": null,//后电动机最大功率[kW]
"rearmaxtorque": null,//后电动机最大扭矩[N.m]
"batterycapacity": null,//电池容量[kwh]
"powerconsumption": null,//耗电量[kwh/100km]
"maxmileage": null,//最大续航里程[km]
"batterywarranty": null,//电池组质保
"batteryfastchargetime": null,//电池快充充电时间
"batteryslowchargetime": null,//电池慢充充电时间
"cltcmaxmileage": null,//CLTC纯电续航[km]
"nedcmaxmileage": null,//NEDC最大续航里程[km]
"wltcmaxmileage": null,//WLTC纯电续航里程[km]
"wltccomprehensivemileage": null,//WLTC综合续航[km]
"cltccomprehensivemileage": null,//CLTC综合续航[km]
"motornum": null,//驱动电机数
"motorlayout": null,//电机布局
"motortype": null,//电机类型
"motormaxhorsepower": null,//电动机总马力[Ps]
"batterytype": null,//电池类型
"batterybrand": null,//电芯品牌
"highvoltagecharging": null,//高压快充平台
"fastchargingpercent": null,//快充电量[%]
"slowchargingpercent": null,//慢充电量[%]
"slowchargingpower": null,//慢充功率[kW]
"fastchargingpower": null,//快充功率[kW]
"batteryenergydensity": null,//电池能量密度[Wh/kg]
"threeelectricwarranty": null,//三电系统质保
"fastcharging": null,//快充功能
"highvoltagefastcharging": null,//高压快充
"chargingpileprice": null,//充电桩价格[元]
"slowchargingportlocation": null,//慢充接口位置
"fastchargingportlocation": null,//快充接口位置
"externalacdischargepower": null//对外交流放电功率[kW]
},
"gearbox": {//变速箱
"gearbox": "7挡干式双离合",//变速箱
"gearnum": "7",//挡位个数
"geartype": "干式双离合变速箱(DCT)",//变速箱类型
"shiftpaddles": "",//换挡拨片
"gearboxmodel": null,//变速箱型号
"fourwheeldrive": null,//四驱形式
"centraldifferential": null,//中央差速器结构
"gearshifting": null//换挡形式
},
"chassissteer": {//底盘转向
"bodystructure": "承载式",//车体结构
"powersteering": "● 电动助力",//转向助力
"frontbraketype": "● 通风盘式",//前制动类型
"rearbraketype": "● 盘式",//后制动类型
"parkingbraketype": "● 电子驻车",//驻车制动类型
"drivemode": "前置前驱",//驱动方式
"airsuspension": "-",//空气悬挂
"adjustablesuspension": "无",//可调悬挂
"frontsuspensiontype": "● 麦弗逊式独立悬架",//前悬挂类型
"rearsuspensiontype": "● 多连杆式独立悬架",//后悬挂类型
"centerdifferentiallock": "-",//中央差速器锁
"chassistype": null,//底盘类别
"axlenum": null,//轴数
"axleload": null,//轴荷
"leafspringnum": null,//钢板弹簧片数(前/后)
"frontsuspension": null,//前悬(mm)
"rearsuspension": null//后悬
},
"wheelbrake": {//车轮制动
"fronttiresize": "● 205/55 R16",//前轮胎规格
"reartiresize": "● 205/55 R16",//后轮胎规格
"sparetiretype": "● ",//备胎类型非全尺寸
"hubmaterial": "● ",//轮毂材料铝合金
"fronttrack": "-",//前轮距(mm)
"reartrack": "-",//后轮距(mm)
"tirenum": null,//轮胎个数
"frontbraketype": "●", //前制动类型通风盘式
"rearbraketype": "●", //后制动类型盘式
"parkingbraketype": "●", //驻车制动类型电子驻车
"sparetireplacement": null//备胎放置方式
},
"activesafety": {//主动安全
"abs": "●",//刹车防抱死(ABS)
"ebd": "●",//电子制动力分配系统(EBD)
"brakeassist": "●",//刹车辅助(EBA/BAS/BA/EVA等)
"tractioncontrol": "●",//牵引力控制(ASR/TCS/TRC/ATC等)
"esp": "●",//动态稳定控制系统(ESP)
"tirepressuremonitoring": "●",//胎压监测装置
"safetybeltprompt": "●",//安全带未系提示
"childseatfixdevice": "●",//儿童安全座椅固定装置
"ldws": "○",//车道偏离预警系统
"activebraking": "○",//主动刹车/主动安全系统
"fatiguereminder": null,//疲劳提醒
"dooropeningwarning": null,//DOW开门预警
"forwardcollisionwarning": null,//前方碰撞预警
"rearcollisionwarning": null,//后方碰撞预警
"drivingrecorder": null,//车载行车记录仪
"roadrescue": null,//紧急道路救援
"sentrymode": null,//哨兵模式/千里眼
"lowspeedwarning": null//低速行车警告
},
"passivesafety": {//被动安全
"airbagdrivingposition": "主●",//驾驶位安全气囊
"airbagfrontpassenger": "副●",//副驾驶位安全气囊
"airbagfrontside": "前●",//前排侧安全气囊
"airbagfronthead": null,//前排头部气囊(气帘)
"airbagknee": "● 主驾膝部气囊",//膝部气囊
"airbagrearside": "后○",//后排侧安全气囊
"airbagrearhead": "前● / 后●",//后排头部气囊(气帘)
"airbagfrontcenter": null,//前排中间气囊
"passivepedestrianprotection": null//被动行人保护
},
"4wdoffroad": {//四驱/越野
"centerdifferentiallock": "-",//中央差速器锁
"differentiallocktype": null,//限滑差速器/差速锁
"lowspeedfourwheeldrive": null,//低速四驱
"creepmode": null,//蠕行模式
"tankturn": null,//坦克转弯
"towhook": null,//拖挂钩
"trailerpowerport": null//拖车取电口
},
"drivingcontrol": {//驾驶操控
"drivemodechoose": null,//驾驶模式选择
"startstopsystem": "●",//启停系统
"automaticparking": "●",//自动驻车
"hillstartassist": "●",//上坡辅助
"hilldescent": "-",//陡坡缓降
"variablesteeringratio": null,//可变转向比
"adjustablesuspension": null,//可调悬挂
"airsuspension": "-",//空气悬挂
"towingmode": null,//拖挂模式
"energyrecovery": null//能量回收系统
},
"drivinghardware": {//驾驶硬件
"frontparkingradar": "前○",//泊车雷达(车前)
"reversingradar": "后●",//倒车雷达(车后)
"reverseimage": "○",//倒车影像倒车影像
"frontperceptioncamera": null,//前方感知摄像头
"camerasnum": null,//摄像头数量
"camerasnumincar": null,//车内摄像头数量
"ultrasonicradarsnum": "100",//超声波雷达数量
"millimeterwaveradarnum": null,//毫米波雷达数量
"maxdetectiondistanceahead": null,//前方最大探测距离
"transparentchassis": "-",//透明底盘/540度影像
"assisteddrivingchip": null,//辅助驾驶芯片
"totalchipcomputingpower": null,//芯片总算力
"frontperceptioncamerapixel": null,//前方感知摄像头像素
"environmentalawarenesscamerapixel": null,//环境感知摄像头像素
"surroundviewcamerapixel": null,//环视摄像头像素
"lidarbrand": null,//激光雷达品牌
"lidarmodel": null,//激光雷达型号
"lidarnum": null,//激光雷达数量
"lidarlinenum": null,//激光雷达线数
"lidardetectiondistance": null,//激光雷达10%反射率探测距离
"lidarpointcloudnum": null//激光雷达点云数量
},
"drivingfunction": {//驾驶功能
"cruisecontrol": "○ 定速巡航,○ 自适应巡航",//巡航系统
"driverassistancesystem": null,//辅助驾驶系统
"driverassistancelevel": null,//辅助驾驶等级
"reversesidewarning": null,//倒车车侧预警系统
"satellitenavigationsystem": "○",//卫星导航系统
"navigationtrafficinfo": null,//导航路况信息显示
"mapbrand": "○ 选配",//地图品牌
"parallelaid": "○",//并线辅助
"lanekeep": "○",//车道保持
"lanecentering": null,//车道居中保持
"roadtrafficsignrecog": null,//道路交通标识识别
"automaticparkingintoplace": "○",//自动泊车入位
"remoteparking": null,//遥控泊车
"memoryparking": null,//记忆泊车
"trackingreverse": null,//循迹倒车
"autolanechangeassist": null,//自动变道辅助
"autorampentryexit": null,//匝道自动驶出/入
"trafficlightrecog": null,//信号灯识别
"remotesummon": null,//远程召唤
"handsoffdetection": null,//方向盘离手检测
"startreminder": null,//起步提醒
"autodrivingsection": null,//自动驾驶辅助路段
"highprecisionmap": null//高精地图
},
"appearanceantitheft": {//外观/防盗
"rearwing": null,//尾翼/扰流板
"hubmaterial": "● 铝合金",//轮毂材料
"electricpulldoor": null,//电动吸合门
"framelessdoor": null,//无框设计车门
"electricluggage": null,//电动行李厢
"trunkpositionmemory": null,//电动后备厢位置记忆
"centrallocking": "●",//中控门锁
"remotekey": "● 遥控钥匙",//钥匙类型
"keylessentry": "○",//无钥匙启动系统
"activeclosedgrille": null,//主动闭合式进气格栅
"remotecontrol": null,//远程遥控功能
"batterypreheating": null,//电池预加热
"discharge": null,//对外放电
"appearancekit": null,//外观套件
"engineantitheft": "●",//发动机电子防盗
"roofluggagerack": "-",//车顶行李箱架
"sidepedal": null,//车侧脚踏板
"hiddendoorhandle": null//隐藏电动门把手
},
"exteriorlight": {//车外灯光
"lowbeamtype": "● 卤素,○ 氙气",//近光灯光源
"headlighttype": "● 卤素,○ 氙气",//远光灯光源
"lightingfeature": null,//灯光特色功能
"daytimerunninglight": "○",//日间行车灯
"adaptivehighandlowbeam": "○",//自适应远近光
"headlightautomaticopen": "○",//自动头灯
"lightsteeringassist": "-",//转向辅助灯
"frontfoglight": "●",//前雾灯
"adjustableheadlight": "●",//大灯高度可调
"headlightdelayoff": "-",//前大灯延时关闭
"headlightrainfogmode": null,//前大灯雨雾模式
"headlightcleaning": null,//大灯清洗装置
"turnheadlight": null,//转向头灯
"scenelightlanguage": null//场景灯语
},
"sunroofglass": {//天窗/玻璃
"skylightopeningmode": "○ 电动天窗",//天窗开合方式
"frontelectricwindow": "●",//前电动车窗
"rearelectricwindow": "●",//后电动车窗
"onetouchwindowlifting": null,//车窗一键升降功能
"antipinchwindow": "●",//车窗防夹手功能
"privacyglass": "●",//隐私玻璃
"sunvisormirror": "●",//遮阳板化妆镜
"rearwiper": "●",//后雨刷器
"sensingwiper": "○",//感应雨刷
"sidewindowsoundproofglass": null,//侧窗多层隔音玻璃
"rearwindowsunshade": "-",//后窗遮阳帘
"heatedwaternozzle": null//可加热喷水嘴
},
"externalrearmirror": {//外后视镜
"electricadjustment": null,//外后视镜功能
"electricfolding": null,//电动折叠
"rearviewmirrormemory": null,//后视镜记忆
"heatedrearviewmirror": null,//后视镜加热
"reversingtiltdown": null,//倒车自动下翻
"foldinglockingcar": null//锁车自动折叠
},
"screensystem": {//屏幕/系统
"consolelcdscreen": "●",//中控台液晶屏
"lcdscreensize": null,//液晶仪表尺寸
"consolelcdscreenresolution": null,//中控屏幕尺寸
"consolelcdscreenpixeldensity": null,//中控屏幕像素密度
"bluetooth": "○",//蓝牙系统
"phoneconnect": null,//手机互联(Carplay&Android)
"voicecontrol": null,//语音控制
"assistantwakeupword": null,//语音助手唤醒词
"wakeupwordfree": null,//语音免唤醒词
"wakeupregion": null,//语音分区域唤醒识别
"continuousspeech": null,//语音连续识别
"seeandsay": null,//可见即可说
"voiceprintrecognition": null,//声纹识别
"carapp": null,//车载APP应用
"intelligentsystem": null,//车载智能系统
"carintelligentchip": null,//车机智能芯片
"rearlcdscreen": null,//后排液晶屏
"rearlcdscreensize": null,//后排液晶屏幕尺寸
"rearscreensnum": null,//后排多媒体屏幕数量
"rearmultimediacontrol": null,//后排控制多媒体
"undercenterscreensize": null,//中控下屏幕尺寸
"carsystemmemory": null,//车机系统内存[GB]
"carsystemstorage": null,//车机系统存储[GB]
"multifingerscreen": null,//多指飞屏操控
"entertainmentscreensize": null,//副驾娱乐屏尺寸
"passengerscreentype": null,//副驾屏幕类型
"facialrecognition": null,//面部识别
"privacyshield": null//隐私声盾
},
"intelligentconfig": {//智能化配置
"internetofvehicle": null,//车联网
"4g": null,//4G/5G网络
"ota": null,//OTA升级
"wifi": null,//Wi-Fi热点
"appremote": null,//手机APP远程功能
"simulatesoundwave": null,//模拟声浪
"ktv": null,//车载KTV
"activenoisecancellation": null//主动降噪
},
"incarcharge": {//车内充电
"chargingport": "● ",//多媒体/充电接口
"usbnum": null,//USB/Type-C接口数量
"usbmaxchargingpower": null,//USB/Type-C最大充电功率
"wirelesscharge": null,//手机无线充电功能
"phonewirelesschargingpower": null,//手机无线充电功率
"luggagepowersocket": null,//行李厢12V电源接口
"powersupply": null//220V/230V电源
},
"seat": {//座椅配置
"sportseat": "-",//运动座椅
"seatmaterial": "● 织物,○ 真皮",//座椅材料
"seatheightadjustment": "",//座椅高低调节
"driverseatadjustmentmode": "● 前后调节,● 靠背调节,● 高低调节",//驾驶座座椅调节方式
"auxiliaryseatadjustmentmode": "● 前后调节,● 靠背调节",//副驾驶座椅调节方式
"driverseatlumbarsupportadjustment": "",//驾驶座腰部支撑调节
"driverseatshouldersupportadjustment": "",//驾驶座肩部支撑调节
"frontseatheadrestadjustment": "",//前座椅头枕调节
"rearseatadjustmentmode": "",//后排座椅调节方式
"rearseatreclineproportion": "",//后排座位放倒比例
"rearseatangleadjustment": "",//后排座椅角度调节
"frontseatcenterarmrest": "有",//前座中央扶手
"rearseatcenterarmrest": "前● / 后●",//后座中央扶手
"seatventilation": "",//座椅通风
"seatheating": "○//座椅加热加热",
"seatmassage": "",//座椅按摩功能
"electricseatmemory": "",//电动座椅记忆
"childseatfixdevice": "●",//儿童安全座椅固定装置
"thirdrowseat": "无",//第三排座椅
"driverseatelectricadjustment": "-",//主座椅电动调节
"auxiliaryseatelectricadjustment": "-",//副座椅电动调节
"secondrowseatelectricadjustment": "无",//第二排座椅电动调节
"frontseatfunction": "无",//前排座椅功能
"rearseatfunction": "无",//后排座椅功能
"secondrowseatadjustment": "主○ / 副○",//第二排座椅调节方式
"seatadjustablebutton": null,//副驾驶位后排可调节按钮
"secondrowseatfunctions": null,//第二排座椅功能
"seatrecliningmethod": "● 比例放倒"//座椅放倒方式
},
"soundinteriorlight": {//音响/车内灯光
"audiobrand": "○ Bang & Olufsen",//音响品牌
"speakernum": "● 8-9喇叭,○ 10-11喇叭,○ ",//扬声器数量
"dolbyatmos": null,//杜比全景声
"interiorairlight": null,//车内氛围灯
"readinglight": "-",//阅读灯
"activeinteriorairlight": null//主动式环境氛围灯
},
"aircondrefrigerator": {//空调/冰箱
"airconditioningcontrolmode": "● 手动空调,○ 自动空调",//空调控制方式
"tempzonecontrol": "○",//温度分区控制
"rearairconditioning": "-",//后排独立空调
"reardischargeoutlet": "○",//后排出风口
"airconditioning": "",//空气调节/花粉过滤
"airpurifyingdevice": "-",//车内空气净化装置
"carrefrigerator": "-",//车载冰箱
"frontairconditioning": "● 手动空调",//前排空调
"fragrance": "无",//香氛系统
"heatpumpairconditioner": null //热泵空调
},
"featuredconfig": {//特色配置
"configname": null,//配置选项
"configcontent": null//配置内容
},
"color": {//车身颜色
"color": "#C7C8CA,水晶银|#F6F6F6,冰川白|#D37201,萨摩亚橙|#374A4A,季风灰|#D91624,米萨诺红|#482807,白鲸棕|#59222B,希纳兹红|#000000,深黑|#FFFFFF,阿玛菲白|#3F6383,海南蓝|#462807,钛金米|#5D6159,莲花灰",//车身颜色
"interiorcolor": "#000000,黑色|#000000/#A8AAA9,黒色/钛灰色|#000000/#DBCBA7,黑色/开士米色|#000000/#DE7838,黑色/卡普里橙|#000000/#544540,黑色/栗棕色"//内饰颜色
},
"optionalpackage": {//选装包
"packagename": "前排座椅电动调整和腰部支撑",//选装配置名称
"packagecontent": "包含:前排座椅电动调节、腰部支撑 ○ 6000元 选配"//选装内容
}
}
}
}
错误返回:
{
"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 | 车辆信息,注释请看返回示例 |
code错误码说明
| code | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 参数错误 |
| 2 | 无记录 |
| 3 | 第三方服务异常 |
| 4 | 签名错误 |
| 5 | 余额不足 |
| 6 | 调用频率超限 |
| 7 | 账号停用 |
| 8 | 接口已停用 |
| 9 | 联系服务商开通接口权限 |
| 10 | ip不在白名单 |
| 11 | 系统异常 |
| 12 | 实名状态错误 |
| 99 | 其他异常,具体返回为准 |
示例代码
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;
/**
* 根据车型查车辆详情 - Java 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_detail/query
*
* 说明:本示例只使用 JDK 原生 API(java.net / java.security),不依赖任何第三方 jar 包,
* 也不需要本项目的工具类,复制到本地即可编译运行:
* javac CarDetailQueryDemo.java
* java CarDetailQueryDemo
*/
public class CarDetailQueryDemo {
/** 数勋分配的 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/car_detail/query";
/** 车型id */
private static final String CARID = "";
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 = "carid=" + urlEncode(CARID);
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();
}
}
# 根据车型查车辆详情 - Python 示例代码
# 接口地址:https://api.shuxuntech.com/v1/car_detail/query
#
# 说明:只使用 Python 标准库(urllib / hashlib / time),不需要 pip 安装任何第三方包,
# 保存为 car_detail_query_demo.py 后直接执行 python car_detail_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/car_detail/query"
# 车型id
CARID = ""
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["carid"] = CARID
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
/**
* 根据车型查车辆详情 - PHP 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_detail/query
*
* 说明:只使用 PHP 内置函数,不需要 composer 安装任何依赖,也不需要 curl 扩展,
* 保存为 car_detail_query_demo.php 后直接执行 php car_detail_query_demo.php 即可。
*/
// 数勋分配的 appKey,请替换为您自己的 appKey
$appKey = "您的appKey";
// 数勋分配的 appSecret,请替换为您自己的 appSecret
$appSecret = "您的appSecret";
// 接口地址
$url = "https://api.shuxuntech.com/v1/car_detail/query";
// 车型id
$carid = "";
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
$timestamp = sprintf('%.0f', microtime(true) * 1000);
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
$sign = hash('sha256', $appKey . $timestamp . $appSecret);
// 3、业务参数
$params = array(
'carid' => $carid,
);
$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;
/**
* 根据车型查车辆详情 - C# 示例代码
* 接口地址:https://api.shuxuntech.com/v1/car_detail/query
*
* 说明:只使用 .NET 基础类库(System.Net.Http / System.Security.Cryptography),不依赖任何第三方包。
* 需要 .NET Framework 4.5 及以上,或 .NET Core / .NET 5 及以上;
* 保存为 CarDetailQueryDemo.cs 后,用 dotnet run 或 VS 控制台项目直接运行即可。
*/
public class CarDetailQueryDemo
{
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private const string AppKey = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private const string AppSecret = "您的appSecret";
/** 接口地址 */
private const string ApiUrl = "https://api.shuxuntech.com/v1/car_detail/query";
/** 车型id */
private const string Carid = "";
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("carid", Carid);
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();
}
}
}
// 根据车型查车辆详情 - Node.js 示例代码
// 接口地址:https://api.shuxuntech.com/v1/car_detail/query
//
// 说明:只使用 Node.js 内置模块(https / crypto),不需要 npm 安装任何第三方包,
// 保存为 car_detail_query_demo.js 后直接执行 node car_detail_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/car_detail/query';
// 车型id
const CARID = '';
// 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({ carid: CARID }).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();
// 根据车型查车辆详情 - Go 示例代码
// 接口地址:https://api.shuxuntech.com/v1/car_detail/query
//
// 说明:只使用 Go 标准库(net/http、crypto/sha256、encoding/hex 等),不需要引入任何第三方包,
// 保存为 car_detail_query_demo.go 后直接执行 go run car_detail_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/car_detail/query"
// 车型id
const carid = ""
// 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("carid", carid)
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
# 根据车型查车辆详情 - curl 示例代码
# 接口地址:https://api.shuxuntech.com/v1/car_detail/query
#
# 说明:只依赖系统自带的 curl 和 openssl(用于计算 sha256),不需要安装任何第三方工具,
# 保存为 car_detail_query_demo.sh 后直接执行 bash car_detail_query_demo.sh 即可。
# 如果系统没有 openssl,可把下面 SIGN 那一行换成注释里的 sha256sum 写法。
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY="您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET="您的appSecret"
# 接口地址
API_URL="https://api.shuxuntech.com/v1/car_detail/query"
# 车型id
CARID=""
# 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 "carid=${CARID}" \
-w "\nHTTP状态码=%{http_code}\n"
java
python
php
c#
nodejs
go
curl
车品牌查询
根据车品牌查车系
根据车系查车型
根据车型查车辆详情
产品详情
API文档
产品价格







