身份证信息接口
平台提供身份证相关信息查询和认证
名词 | 说明 | 备注 |
---|---|---|
userID | 接入方式用户 ID | 由万物芯联分配 |
secretKey | 接口通信密钥 | 由万物芯联分配 |
TDES | triple DES 加密 | 加密填充方式 ECB/PKCS#5 |
Base64 encode / Base64 decode | Base64 加/解码 |
身份认证信息接口调用是向服务端地址发送 HTTP POST 请求,并按照接口说明在请求中加入相应请求数据,调用后系统会返回处理结果。请求及返回结果都使用 UTF-8 字符集进行编码。
http://api.althico.com/althico/api/IDinfo/
请求数据使用 json 格式
字段 | 类型 | 说明 |
---|---|---|
userID | string | 用户ID |
encryption | string | 每个接口请求参数加密和编 码后的数据 |
示列:
x#1 接口请求参数为 "A" :
{
"name":"张三",
"idnum":"300000000000000000"
}
#2 使用 TDES 加密 "A",得到数据 "B"
#3 然后使用 Base64 encode "B",得到字符串数据 "C"
#4 最终提交到后台的数据
{
"userID":"100000",
"encryption":"C"
}
响应数据使用 json 格式
字段 | 类型 | 说明 |
---|---|---|
status | string | 响应状态值 |
message | string | 响应描述 |
data | string | 响应原始数据,TDES 加密, 然后使用base64 编码生成数据, 原始数据是json或者string类型 |
示列:
xxxxxxxxxx
#1 响应数据
{
"status": "0",
"message": "success",
"data":"C"
}
#2 Base64 dcode 数据 "C",得到数据 "B"
#3 TDES 解密数据 B,得到接口响应的原始数据 "A"
#4 数据 "A" 根据接口定义,类型可以是 json 或者 string
人头像和公安数据库数据比对
地址 /portraitMatch
参数
字段 | 类型 | 说明 |
---|---|---|
name | string | 身份证姓名 |
idnum | string | 身份证号码 |
image | string | 头像的数据 Base64 encode |
requestTrace | String | 客户请求号 |
示列
xxxxxxxxxx
{
"name":"张三",
"idnum":"300000000000000000",
"image":"base64 encode"
}
响应
类型 | 说明 |
---|---|
string | 相似度 "0" ~ "100" |
示列
xxxxxxxxxx
"90"
查询个人不良信息
地址 /badInfoQuery
参数
字段 | 类型 | 说明 |
---|---|---|
name | string | 身份证姓名 |
idnum | string | 身份证号码 |
requestTrace | String | 客户请求号 |
示列
xxxxxxxxxx
{
"name":"张三",
"idnum":"300000000000000000"
}
响应
字段 | 类型 | 说明 |
---|---|---|
badinfo | string | 是否存在不良信息,"0" 不存在,"1" 存在 |
items | object | 不良信息列表 |
items.caseSource | string | 不良信息代码 |
items.caseTime | string | 案发时间 |
示列
xxxxxxxxxx
{
"badinfo":"0",
"items":{
"caseSource":"1",
"caseTime":"2019-10-10"
}
}
OCR简项,输入为身份证正面照片,识别姓名、身份证号
地址 /ocrSimple
参数
字段 | 类型 | 说明 |
---|---|---|
image | string | 头像数据 Base64 encode |
requestTrace | String | 客户请求号 |
示列
xxxxxxxxxx
{
"image":"Base64 encode"
}
响应
字段 | 类型 | 说明 |
---|---|---|
name | string | 身份证姓名 |
idnum | string | 身份证号码 |
示列
xxxxxxxxxx
{
"name":"张三",
"idnum":"300000000000000000"
}
OCR多项,识别身份证正面或反面信息
正面:识别姓名、身份证号、地址、生日、民族、性别、身份证号码截图、身份证头像
反面:签发机关、有效期
地址 /ocrMultiple
参数
字段 | 类型 | 说明 |
---|---|---|
image | string | 头像数据 Base64 encode |
requestTrace | String | 客户请求号 |
示列
xxxxxxxxxx
{
"image":"Base64 encode"
}
响应
字段 | 类型 | 说明 |
---|---|---|
name | string | 身份证姓名 |
idnum | string | 身份证号码 |
address | string | 地址(例** 省 市 区 ** 路 42 号 3 号楼 3 单元 201 号) |
birthday | string | 生日(例:1980年 4 月 25 日) |
nation | string | 民族 |
sex | string | 性别 |
type | string | 第二代身份证 |
issuingAuthorit | string | 签发机关 |
image | string | 头像图片 |
validPeriod | string | 有效期 2012.07 .24 - 2022.07 .24 |
示列
xxxxxxxxxx
{
"name":"张三",
"idnum":"300000000000000000",
"address":"广东省深圳市",
"birthday":"1980年 4 月 25 日",
"nation":"汉",
"sex":"男",
"type":"第二代身份证",
"issuingAuthorit":"公安局",
"image":"xxx",
"validPeriod":"2012.07.24 - 2022.07.24"
}
两张照片进行比对,验证两张人像图像相似度
地址 /photoCompare
参数
字段 | 类型 | 说明 |
---|---|---|
image1 | string | 头像数据 Base64 encode |
image2 | string | 头像数据 Base64 encode |
requestTrace | String | 客户请求号 |
示列
xxxxxxxxxx
{
"image1":"xxx",
"image2":"xxx",
}
响应
类型 | 说明 |
---|---|
string | 相似度 "0" ~ "100" |
示列
xxxxxxxxxx
"90"
通过NFC读取身份证信息
地址 /idInfoGet
参数
字段 | 类型 | 说明 |
---|---|---|
reqId | string | NFC读取库返回的 ID |
requestTrace | String | 客户请求号 |
示列
xxxxxxxxxx
{
"reqId":"123"
}
响应
字段 | 类型 | 说明 |
---|---|---|
name | string | 身份证姓名 |
idnum | string | 身份证号码 |
address | string | 地址(例** 省 ** 市 ** 区 ** 路 42 号 3 号楼 3 单元 201 号) |
birthDate | string | 出生年月生日(例:19800425) |
nation | string | 民族 |
sex | string | 性别 |
idType | string | 第二代身份证 |
signingOrganization | string | 签发机关 |
image | string | 头像图片(加密数据) |
beginTime | string | 有效开始时间 |
endTime | string | 有效结束时间 |
classify | string | 分类 |
示列
xxxxxxxxxx
{
"name":"张三",
"idnum":"300000000000000000",
"address":"广东省深圳市",
"birthDate":"19800425",
"nation":"汉",
"sex":"男",
"idType":"01",
"signingOrganization":"公安局",
"image":"xxx",
"beginTime":"20120724",
"endTime":"20120724",
"classify":"1"
}
获取设备授权的 license key
地址 /getLicKey
参数
字段 | 类型 | 说明 |
---|---|---|
type | 设备类型 | 目前总为 1 |
示列
xxxxxxxxxx
{
"type": "1"
}
响应
类型 | 说明 |
---|---|
string | license key |
示列
xxxxxxxxxx
"1245556745674576"
提示码 | 描述 | 备注 |
---|---|---|
0 | 成功 | |
1 | 请求数据错误,请联系系统管理员处理 | |
1001 | 系统异常 | |
1003 | 内部通讯异常 | |
1005 | LICENSE过期 | |
0198002 | reqid格式不正确 | |
0301000 | 验证失败 | 免费 |
0301001 | 库中无此证件号码 | 收费 |
0301002 | 姓名和证件号码不配备 | 收费 |
0301004 | 姓名不正确(长度不正确或中文乱码) | 免费 |
0399001 | 库中未查到结果数据(信息获取类) | 收费 |
0399005 | image 无法正确识别 | 免费 |
0399006 | 人脸库中的照片检测不到人脸 | 免费 |
0399007 | 用户上传的照片检测不到人脸 | 免费 |
0399008 | 人脸比对失败 | 免费 |
0399010 | 身份证号不正确 | 免费 |
0399023 | 公安库找不到照片 | 收费 |
0400000 | 身份对比系统异常 | 免费 |
0599001 | 账户余额不足 |
xxxxxxxxxx
public static final String BASE_URL = "http://api.althico.com";
public static final String BASE_APP = BASE_URL + "/althico/api/IDinfo/";
public static final String ALTHICO_PHOTO_CHECK = BASE_APP + "portraitMatch";
public static final String ID_INFO_GET = BASE_APP + "idInfoGet";
public static String mUserID = "01000101000000012019061000000069";
public static String mSecretKey = "197950099007131002042569";
public static String photoCheck() {
PhotoCheckReq en = new PhotoCheckReq();
BaseReq req = new BaseReq();
try {
en.image = Base64.getEncoder().encodeToString(Files.readAllBytes(new File("pic.jpg").toPath()));
} catch (IOException e) {
e.printStackTrace();
return null;
}
en.idnum = "410505199611157000";
en.name = "王周";
req.userID = mUserID;
req.encryption = Base64.getEncoder().encodeToString(
TDesEncrypt(mSecretKey.getBytes(), JSON.toJSONString(en).getBytes()));
String respData = SdkTest.httpPost(ALTHICO_PHOTO_CHECK,
"application/json", JSON.toJSONString(req));
if (respData == null) {
return null;
}
BaseRsp resp = JSON.parseObject(respData, BaseRsp.class);
if (resp == null) {
return null;
}
if (!resp.status.equals("0")) {
return null;
}
String result = new String(
TDesDecrypt(mSecretKey.getBytes(),
Base64.getDecoder().decode(resp.data)));
return result;
}
public static IdCardInfo nfcGetIdCardInfo(String reqID) {
NfcIdCarInforReq en = new NfcIdCarInforReq();
BaseReq req = new BaseReq();
en.reqId = reqID;
req.userID = mUserID;
req.encryption = Base64.getEncoder().encodeToString(
TDesEncrypt(mSecretKey.getBytes(), JSON.toJSONString(en).getBytes()));
String respData = SdkTest.httpPost(ID_INFO_GET,
"application/json", JSON.toJSONString(req));
if (respData == null) {
return null;
}
BaseRsp resp = JSON.parseObject(respData, BaseRsp.class);
if (resp == null) {
return null;
}
if (!resp.status.equals("0")) {
return null;
}
IdCardInfo result = JSON.parseObject(
TDesDecrypt(mSecretKey.getBytes(),
Base64.getDecoder().decode(resp.data)),
IdCardInfo.class);
return result;
}
public static String toReqData(Object o) {
return null;
}
public static byte[] TDesDecrypt(byte[] key, byte[] en) {
try {
SecretKey deskey = new SecretKeySpec(key, "DESede");
Cipher c1 = Cipher.getInstance("DESede/ECB/PKCS5Padding");
c1.init(Cipher.DECRYPT_MODE, deskey);
return c1.doFinal(en);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static byte[] TDesEncrypt(byte[] key, byte[] en) {
try {
SecretKey deskey = new SecretKeySpec(key, "DESede");
Cipher c1 = Cipher.getInstance("DESede/ECB/PKCS5Padding");
c1.init(Cipher.ENCRYPT_MODE, deskey);
return c1.doFinal(en);
} catch (Exception e) {
}
return null;
}
public static class PhotoCheckReq {
public String name;
public String idnum;
public String image;
}
public static class NfcIdCarInforReq {
public String reqId;
}
public static class BaseReq {
public String userID;
public String encryption;
}
public static class BaseRsp {
public String status;
public String message;
public String data;
}
public static class IdCardInfo {
public String idType;
public String classify;
public String name;
public String sex;
public String nation;
public String birthDate;
public String address;
public String idnum;
public String signingOrganization;
public String beginTime;
public String endTime;
public String image;
}