调用说明
接口统一域名
对接流程

Step 1. 联系客服(0755-84362888)或者进入信用云官网提交信息联系我们来获取测试的apiKey 和apiSecret

Step 2. 获取apiKey 和apiSecret后,利用文档完成接口的开发和调试

Step 3. 联系客服获取正式的apiKey和apiSecret完成上线操作

签名验证
              
  apiKey: (第三方app-key,是三方开发者系统的唯一标示)
            
  secret: (第三方开发人员调用信用云openapi时用于计算签名的参数.请妥善保管)

编码
编码统一都采用 UTF-8

默认数据传输都采用JSON格式,请求Header中设置content-type为application/json;charset=utf-8

如有特殊要求具体接口文档会标明
接口返回报文
第三方开发人员需判断http的响应码,如下:

              
  200表示调用成功
  
  500,502表示系统内部错误,可稍后再试
  
  401表示未授权
  
  403表示签名验证失败
  
  400表示业务处理错误.
              
如果接口没有特殊说明,接口统一返回格式如下:
              
  {
      "code": "CM10000",//返回错误码
      "errorMessage": null,//错误信息
      "data": "pass",//返回数据
      "success": true //请求是否成功.
  }

              
字段说明:
字段名类型字段说明
codeString状态码
errorMessageString错误描述信息
dataObject返回结果,接口的具体返回值请参阅Api详细说明
successBoolean接口执行结果,为true表示执行成功,此时data值返回结果数据; 为false表示执行失败,此时code返回具体的错误码,errorMessage返回具体的错误信息
系统参数
系统参数指和具体的业务无关,但是每次接口调用都需要的输入参数,系统参数通过http请求的header传入,系统参数如下:
字段名类型字段说明
apiKeyString开发者秘钥
timstampNumber接口调用时的时间戳,即当前时间戳(时间戳:当前距离Epoch(1970年1月1日) 以秒计算的时间,即unix-timestamp. 请求过期时间为5分钟.
signString输入参数的签名结果,签名方法请参考计算签名
计算签名
              
  以企业工商基本信息接口为例(/api/v1/enterprise/basic/base-info)
              
拼接

注意:body里面的参数不参与签名,只有以下四个参数参与签名
              
  例如:uri=/api/v1/enterprise/basic/base-info
  apiKey=ntjhb0v6thrwaujqttytbzayow5ozw
  timestamp=1572416299710
  secret=m2i5oddjmgzhmgi0ndk2m2jhytjkmznjmzdhymfkmwq
  拼接之后的结果为:/api/v1/enterprise/basic/base-info?apiKey=ntjhb0v6thrwaujqttytbzayow5ozw×tamp=1572416299710m2i5oddjmgzhmgi0ndk2m2jhytjkmznjmzdhymfkmwq

              
MD5计算签名
              
  上述拼接好的字符串的MD5签名结果为 
  c617b53e9b61e54cfe851a869890fc6e

              
完整请求
              
  $ curl -X POST \
   http:///api/v1/enterprise/basic/base-info \
   -H 'Content-Type: application/json' \
   -H 'apiKey: ntjhb0v6thrwaujqttytbzayow5ozw' \
   -H 'sign: c617b53e9b61e54cfe851a869890fc6e' \
   -H 'timestamp: 1572416299710' \
   -d '{"companyId":"239589","companyName":"中证信用增进股份有限公司","legRepresent":
  "牛冠兴","foundDt":"2015-05-27 12:00:00"}'


              
通用错误码
错误码(code)含义
CM10000请求成功
CM10001请求参数无效
CM10003日期格式错误.yyyy-MM-dd
CM10004服务器异常,请稍后再试,如有疑问请联系客服
CM10005请求头必选包含apiKey,timestamp,sign信息
CM19999未知的错误
AU20001验证签名不通过
AU20002权限校验不通过
AU20003请求已经过期
业务错误码
错误码(code)含义
ME40001参数不正确
ME40002客户不存在
ME40004资源无法找到
ME40005无对应产品
ME40008该请求已经过期
ME40009内部服务错误
ME49998Hystrix,企业征信(cloud-mercury)服务器异常,请稍后再试.触发熔断返回此错误码
ME49999未知的错误
MB50001非法用户
MB50002调用企业接口余额不足
MB50003调用企业接口参数错误
MB50004无法找到匹配的信息
MB50005系统繁忙
MB50006IO错误
MB50007调用企业接口连接超时
MB50008调用企业接口响应超时
MB50009数据库错误
MB50010服务未上线
MB50011URL地址失效
MB50012Hystrix,企业征信(cloud-dmp)服务器异常,请稍后再试.触发熔断返回此错误码
JAVA代码示例

  public class CreditClient {

    private static final Logger logger = LoggerFactory.getLogger(CreditClient.class);
    public  OkHttpClient okHttpClient;

    public static final long DEFAULT_READ_TIMEOUT = 30*1000;
    public static final long DEFAULT_WRITE_TIMEOUT = 30*1000;
    public static final long DEFAULT_CONNECT_TIMEOUT = 5*1000;

    private String apiKey;
    private String basePath;
    private String secret;

    private CreditClient(String apiKey,String secret,String basePath,Long readTimeout,Long writeTimeout,Long connectTimeout) {
        this.apiKey = apiKey;
        this.basePath = basePath;
        this.secret = secret;
        okHttpClient = new OkHttpClient
                .Builder()
                .readTimeout(readTimeout, TimeUnit.MILLISECONDS)
                .writeTimeout(writeTimeout, TimeUnit.MILLISECONDS)
                .connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
                .retryOnConnectionFailure(true)
                .build();
    }

    private CreditClient(String apiKey,String secret,String basePath) {
        this(apiKey,secret,basePath, DEFAULT_READ_TIMEOUT,DEFAULT_WRITE_TIMEOUT,DEFAULT_CONNECT_TIMEOUT);
    }

    private  String executeRaw(String httpMethod, String url, RequestBody requestBody,
                                      Map queryMap,
                                      Map headerMap) throws Exception {

        url = url + createOrderedUrlParamFromMap(queryMap);
        //组装Headers
        Headers.Builder headerBuilder = new Headers.Builder();
        if (headerMap != null && !headerMap.isEmpty()) {
            headerMap.forEach((k, v) -> headerBuilder.add(k, v));
        }
        //组装Request
        Request request
                = new Request.Builder()
                .url(url)
                .method(httpMethod, requestBody)
                .headers(headerBuilder.build())
                .build();

        //发送请求
        Call call = okHttpClient.newCall(request);
        Response response = call.execute();

        //校验返回
        if (!response.isSuccessful()) {
            //解析错误信息
            String repsStr = response.body().string();
            logger.warn(repsStr);
            ResponseVo responseVo = JsonUtils.toObj(repsStr, ResponseVo.class);
            if (responseVo == null || responseVo.getCode() == null) {
                throw new RuntimeException(
                        "HttpClient调用失败"
                                + ", httpStatus=" + response.code()
                                + ", URL=" + response.request().url()
                                + ", 错误信息:" + repsStr);

            } else {
                throw new RuntimeException("HttpClient调用失败"
                        + ", URL=" + response.request().url()
                        + ",错误信息:" + responseVo.toString());
            }
        }
        String body = response.body().string();

        return body;
    }


    public  ResponseVo execute(String uri,
                                     String httpMethod,
                                     RequestBody requestBody,
                                     Map paraMap,
                                     Map headMap) throws Exception {

        if (null == paraMap) {
            paraMap = Maps.newHashMap();
        }
        if (null == headMap) {
            headMap = Maps.newHashMap();
        }
        long timestamp = System.currentTimeMillis()/1000;
         headMap = new ImmutableMap.Builder().putAll(headMap).put(Const.API_HEAD_KEY, apiKey)
                .put(Const.API_HEAD_TIMESTAMP, timestamp + "")
                .put(Const.API_HEAD_SIGN,
                        Utils.calSign(apiKey, secret, timestamp,
                                uri, ImmutableMap.copyOf(paraMap)))
                .build();
         String body = executeRaw(httpMethod, basePath + uri, requestBody, paraMap, headMap);
        ResponseVo responseVo = JsonUtils.toObj(body, ResponseVo.class);
        return responseVo;
    }