顺丰目前提供了两种对接方式:
一种是开发者自助对接顺丰的接口。
在顺丰丰桥上先注册账户后,申请成为开发者后,再根据顺丰的文档要求对接。然而,这种方式面单审核期长,整个流程较为繁琐,并且需要开发者长期维护接口,顺丰接口提供给用户自主打单的服务也仅提返回面单的pdf文件。
另一种方式是通过对接第三方快递电子面单打印API接口的服务商(例如快递100API)
如果对接的快递公司数量较多,那么接入这种已经封装好多家快递的电子面单打印接口的集成接口,是个更加方便快捷的选择。仅需通过几步,即可实现接入顺丰快递的云打印电子面单接口API,实现获取顺丰快递电子面单,打印电子面单,复打电子面单,打印接口回调等多种功能。而且面单返回形式也多样,提供pdf,图片,html等多种形式,轻松实现远程打印。
顺丰快递电子面单接口
顺丰云打印电子面单API接口提供方:快递100API(详见技术文档)
电子面单打印接口类型:顺丰电子面单打印接口,顺丰电子面单打印接口,顺丰电子面单复打接口,顺丰电子面单自定义打印接口,电子面单OCR识别接口
编程语言要求:Json。提供统一格式的HTTP POST或GET调用接口,并返回统一格式JSON数据。
一,顺丰快递云打印电子面单接口API功能介绍
顺丰快递电子面单API服务提供了获取物流单号、打印电子面单的功能,满足企业的快速打单、回传物流单号的需求。
顺丰快递电子面单API已升级迭代到V2版本,提供更简单易用的模板编辑工具,并在云打印服务方式上做了升级,新对接客户建议直接使用电子面单接口V2版接口(配套快递公司模板V2);
快递100的顺丰快递电子面单API支持45+家快递公司网点面单打印、主流电商平台(淘宝、京东、拼多多)面单打印以及国际快递公司面单打印。具体列表清查看参数字典
二,电子面单打印API应用场景:
商家通过接口打印电子面单,并对商品包装贴单,快递员取件发货;
商家可通过接口远程让仓库、发货点打单,不同部门也能调用同一台设备;
接口可自动回传单号到系统,省去操作员手动关联订单和运单,提升企业信息化水平。
三,接入顺丰快递电子面单接口API的三个步骤:
注册快递100企业版免费账号。注册后有50单电子面单调试单量赠送,客户无需充值可先调试对接;
沙箱测试。快递100管理后台-调试工具-电子面单-mock模式支持沙箱测试,填入的账号信息不会提交至快递公司校验;
调用接口。API接口调用无测试环境,但提交打印请求后不揽收不会计算快递费,快递公司对单号有一定的回收机制,客户接口调试只需在订单内备注、寄件人或收件人等写明“测试”或“无需取件”字段。
四:顺丰快递电子面单接口Demo示例代码:
1,电子面单提交打印请求接口示例:
public void testLabelOrder() throws Exception {
ManInfo recManInfo = new ManInfo();
recManInfo.setName("张三");
recManInfo.setMobile("15999566666");
recManInfo.setPrintAddr("广东省深圳市南山区科技南十二路");
ManInfo sendManInfo = new ManInfo();
sendManInfo.setName("李四");
sendManInfo.setMobile("15999566666");
sendManInfo.setPrintAddr("北京市海淀区xxx路");
OrderReq orderReq = new OrderReq();
orderReq.setKuaidicom(CompanyConstant.ZJS);
orderReq.setCount(1);
orderReq.setSiid(siid);
orderReq.setTempId("60f6c17c7c223700131d8bc3");
orderReq.setSendMan(sendManInfo);
orderReq.setRecMan(recManInfo);
orderReq.setPrintType(PrintType.CLOUD);
String param = new Gson().toJson(orderReq);
String t = System.currentTimeMillis() + "";
PrintReq printReq = new PrintReq();
printReq.setT(t);
printReq.setKey(key);
printReq.setSign(SignUtils.printSign(param,t,key,secret));
printReq.setMethod(ApiInfoConstant.ORDER);
printReq.setParam(param);
IBaseClient baseClient = new LabelV2();
System.out.println(baseClient.execute(printReq));
2,电子面单复打接口
请求数据:
public void testPrintOld() throws Exception {
RepeatPrintReq repeatPrintReq = new RepeatPrintReq();
repeatPrintReq.setTaskId("027B34AD22DE4F299643A13642B70D5F");
String param = new Gson().toJson(repeatPrintReq);
String t = System.currentTimeMillis() + "";
PrintReq printReq = new PrintReq();
printReq.setT(t);
printReq.setKey(key);
printReq.setSign(SignUtils.printSign(param,t,key,secret));
printReq.setMethod(ApiInfoConstant.CLOUD_PRINT_OLD_METHOD);
printReq.setParam(param);
IBaseClient baseClient = new LabelV2();
System.out.println(baseClient.execute(printReq));
3,电子面单取消:
请求数据:
public void testLabelCancel() throws Exception{
LabelCancelParam labelCancelParam = new LabelCancelParam();
labelCancelParam.setPartnerId("test");
labelCancelParam.setKuaidicom(CompanyConstant.SF);
labelCancelParam.setKuaidinum("SF1342567604302");
//快递公司订单号(对应提交打印请求时返回的kdComOrderNum,如果没有可以不传,否则必传)
labelCancelParam.setOrderId("01639366271685GNkZEX");
labelCancelParam.setReason("暂时不寄了");
String param = new Gson().toJson(labelCancelParam);
String t = System.currentTimeMillis() + "";
PrintReq printReq = new PrintReq();
printReq.setT(t);
printReq.setKey(key);
printReq.setMethod(ApiInfoConstant.CANCEL_METHOD);
printReq.setSign(SignUtils.printSign(param,t,key,secret));
printReq.setParam(param);
IBaseClient baseClient = new LabelCancel();
System.out.println(baseClient.execute(printReq));}
4,顺丰国际快递的电子面单云打印接口API
请求数据:
public void testShipment() throws Exception {
ShipmentReq shipmentReq = new ShipmentReq();
shipmentReq.setPartnerId("");
shipmentReq.setPartnerKey("");
shipmentReq.setPartnerSecret("");
shipmentReq.setCode("");
shipmentReq.setKuaidicom("fedex");
shipmentReq.setCargo("invoice");
shipmentReq.setExpType("FedEx International First®");
shipmentReq.setUnitOfMeasurement("SU");
shipmentReq.setWeight(50.00);
shipmentReq.setCustomsValue(1000.00);
ManInfo sendMan = new ManInfo();
sendMan.setName("test");
sendMan.setMobile("16888888888");
sendMan.setCountryCode("CN");
sendMan.setCity("SHENZHEN");
sendMan.setAddr("Kingdee Software Park");
sendMan.setDistrict("Hi-tech Park,Nanshang District");
sendMan.setZipcode("518057");
sendMan.setEmail("test@qq.com");
shipmentReq.setSendMan(sendMan);
ManInfo recMan = new ManInfo();
recMan.setName("test");
recMan.setMobile("16888888888");
recMan.setCountryCode("US");
recMan.setCity("NEW YORK");
recMan.setAddr(" 70 Washington Square South");
recMan.setZipcode("10012");
recMan.setEmail("test@qq.com");
recMan.setStateOrProvinceCode("NY");
shipmentReq.setRecMan(recMan);
List<PackageInfo> packageInfoList = new ArrayList<>();
PackageInfo packageInfo = new PackageInfo();
packageInfo.setLength(10.00);
packageInfo.setWidth(20.00);
packageInfo.setHeight(10.00);
packageInfo.setWeight(50.00);
packageInfoList.add(packageInfo);
shipmentReq.setPackageInfos(packageInfoList);
List<ExportInfo> exportInfoList = new ArrayList<>();
ExportInfo exportInfo = new ExportInfo();
exportInfo.setDesc("test");
exportInfo.setGrossWeight(50.00);
exportInfo.setQuantity(1);
exportInfo.setUnitPrice(1000.00);
exportInfo.setQuantityUnitOfMeasurement("PCS");
exportInfo.setManufacturingCountryCode("CN");
exportInfoList.add(exportInfo);
shipmentReq.setExportInfos(exportInfoList);
CustomsClearance customsClearance = new CustomsClearance();
customsClearance.setPurpose("GIFT");
customsClearance.setDocument(true);
String param = new Gson().toJson(shipmentReq);
String t = System.currentTimeMillis() + "";
String sign = SignUtils.printSign(param,t,key,secret);
PrintReq printReq = new PrintReq();
printReq.setKey(key);
printReq.setMethod(ApiInfoConstant.ELECTRONIC_ORDER_PIC_METHOD);
printReq.setSign(sign);
printReq.setParam(param);
printReq.setT(t);
IBaseClient baseClient = new InternationalShipment();
//国际面单耗时比较长,尽量调整10s以上
baseClient.setTimeOut(1000,10000);
System.out.println(baseClient.execute(printReq));}
官方技术支持:https://api.kuaidi100.com/document/5eb9f5b686b0df41883139f4.html