获取快递公司代码
发货接口需要传入快递公司的代码,市面上很多家快递公司,此接口可以获取主流快递公司的代码以及快递单号的检验规则。 此接口一般不需要每次都调用,您获取最新数据后,可以作为基础数据存到自己的系统中。
1.请求参数
请求URL:
POST https://kf.fw199.com/gateway/taobao/logistices/getcompany
参数名 | 类型 | 说明 | 示例 |
---|---|---|---|
appid | String | 合作伙伴AppId | uwkahf@jfs92 |
timestamp | String | 当前时间戳 | |
tb_seller_nick | String | 淘宝卖家店铺登录账号,非店铺名称. 如果不传入将用代理店铺。建议自行传入。 | kingdo |
sign | String | 接口签名 | 如何计算生成见示例代码 |
order_mode | string | 推荐物流公司的下单方式.可选值:offline(电话联系/自己联系),online(在线下单),all(即电话联系又在线下单). | |
is_recommended | bool | 是否查询推荐物流公司.可选值:true,false.如果不提供此参数,将会返回所有支持电话联系的物流公司. |
2. 请求示例代码(Java)
@Test
public void getLogisticesCompany() throws Exception {
String result ="";
String tb_seller_nick = Config.TBSellerNick ; //要查询支付宝的淘宝商家
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost( Config.LogisticesCompanyUrl );
//业务参数
Map<String, String> data = new HashMap<String, String>();
data.put("appid", Config.AppId);
data.put("tb_seller_nick", tb_seller_nick);
Long timestamp = System.currentTimeMillis() / 1000;
data.put("timestamp", timestamp.toString());
// 推荐物流公司的下单方式.可选值:offline(电话联系/自己联系),online(在线下单),all(即电话联系又在线下单).
// 此参数仅仅用于is_recommended 为ture时。就是说对于推荐物流公司才可用.如果不选择此参数将会返回推荐物流中支持电话联系的物流公司.
// 是否查询推荐物流公司.可选值:true,false.如果不提供此参数,将会返回所有支持电话联系的物流公司.
data.put("is_recommended", "true");
data.put("order_mode","offline");
// 参数签名
data.put("sign", Utils.Sign(data,Config.AppSecret));
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
for (Map.Entry<String, String> entry : data.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
//发起POST请求
try {
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
HttpResponse httpResponse = httpclient.execute(httpPost);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
result = EntityUtils.toString(httpResponse.getEntity());
} else {
result = ("doPost Error Response: " + httpResponse.getStatusLine().toString());
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(result);
}
}
3. 返回结果如下:
{
"code": 0,
"message": "ok",
"data": [{
"code": "ZJS", // 资源编码(发货使用)
"id": 103,
"name": "宅急送",
"reg_mail_no": "^[a-zA-Z0-9]{10}$|^(42|16)[0-9]{8}$|^A[0-9]{12}"
}, {
"code": "SF", // 资源编码(发货使用)
"id": 505,
"name": "顺丰速运",
"reg_mail_no": "^[A-Za-z0-9-]{4,35}$"
} ]
}
说明: code为0表示成功,非0为失败,message会包含失败原因。失败时一定要注意,可能商户授权过期,或是参数有误。 data为快递公司的集合,由于篇幅有限,省略部分数据。data集合中的对象关系如下:
code: 资源编码(发货使用),name: 快递公司名称,reg_mail_no: 快递单号的规则。
注意:此接口返回的code用于对应快递发货时使用,电子面单取号时快递公司的代码用”获取菜鸟标准电子面单模板“中的cp_code。两者代码不要搞混,具体的区分见 https://open.taobao.com/doc.htm?docId=105085&docType=1
4. 常用快递公司名称及发货代码
菜鸟中的快递公司会有变化,请通过接口获取最新的快递公司信息。
{
"code": 0,
"message": "ok",
"data": [
{
"code": "POST",
"id": 1,
"name": "中国邮政",
"reg_mail_no": ""
},
{
"code": "OTHER",
"id": -1,
"name": "其他",
"reg_mail_no": "^[A-Za-z0-9-]{4,35}$"
},
{
"code": "CYEXP",
"id": 511,
"name": "长宇",
"reg_mail_no": ""
},
{
"code": "DTW",
"id": 512,
"name": "大田",
"reg_mail_no": ""
},
{
"code": "YUD",
"id": 513,
"name": "长发",
"reg_mail_no": ""
},
{
"code": "DISTRIBUTOR_13211725",
"id": 1216000000124268,
"name": "跨越速运",
"reg_mail_no": ""
},
{
"code": "DISTRIBUTOR_30493846",
"id": 1216000000361492,
"name": "平安达腾飞快递",
"reg_mail_no": "10位纯数字单如:1661783770"
},
{
"code": "DISTRIBUTOR_13222803",
"id": 1216000000125358,
"name": "中通快运",
"reg_mail_no": ""
},
{
"code": "PKGJWL",
"id": 21000038002,
"name": "派易国际物流77",
"reg_mail_no": ""
},
{
"code": "DISTRIBUTOR_13148625",
"id": 6000100034229,
"name": "菜鸟大件-中铁配",
"reg_mail_no": "^\\d{15,}[-\\d]+$|^[0-9]{10}|[0-9]{12}$"
},
{
"code": "DISTRIBUTOR_13159132",
"id": 6000100034186,
"name": "菜鸟大件-日日顺配",
"reg_mail_no": ""
},
{
"code": "DISTRIBUTOR_30464910",
"id": 1216000000349602,
"name": "丰网速运",
"reg_mail_no": ""
},
{
"code": "DISTRIBUTOR_30292473",
"id": 1216000000280959,
"name": "大食品商家自配",
"reg_mail_no": "^[A-Za-z0-9-]{4,35}$"
},
{
"code": "WND",
"id": 21000127009,
"name": "WnDirect",
"reg_mail_no": ""
},
{
"code": "GZLT",
"id": 200427,
"name": "飞远配送 ",
"reg_mail_no": ""
},
{
"code": "DISTRIBUTOR_1710055",
"id": 5000000178661,
"name": "邮政标准快递",
"reg_mail_no": "^(10)[0-9]{11}$|^(11)[0-9]{11}$"
},
{
"code": "DISTRIBUTOR_13484485",
"id": 1216000000158681,
"name": "顺心捷达",
"reg_mail_no": "^[0-9]{8}$;^[0-9]{10}$"
},
{
"code": "YC",
"id": 1139,
"name": "远长",
"reg_mail_no": "^96[0-9]{12}$"
},
{
"code": "DFH",
"id": 1137,
"name": "东方汇",
"reg_mail_no": "^[0-9]{10}$|^LBX[0-9]{15}-[2-9AZ]{1}-[1-9A-Z]{1}"
},
{
"code": "UNIPS",
"id": 1237,
"name": "发网",
"reg_mail_no": ""
},
{
"code": "MGSD",
"id": 21000007003,
"name": "美国速递",
"reg_mail_no": ""
},
{
"code": "BHWL",
"id": 21000053037,
"name": "保宏物流",
"reg_mail_no": ""
},
{
"code": "ZJS",
"id": 103,
"name": "宅急送",
"reg_mail_no": "^[a-zA-Z0-9]{10}$|^(42|16)[0-9]{8}$|^A[0-9]{12}"
},
{
"code": "SF",
"id": 505,
"name": "顺丰速运",
"reg_mail_no": "^[A-Za-z0-9-]{4,35}$"
},
{
"code": "STO",
"id": 100,
"name": "申通快递",
"reg_mail_no": "^(268|888|588|688|368|468|568|668|768|868|968)[0-9]{9}$|^(11|22|40|268|888|588|688|368|468|568|668|768|868|968)[0-9]{10}$|^(STO)[0-9]{10}$|^(33)[0-9]{11}$|^(4)[0-9]{12}$|^(55)[0-9]{11}$|^(66)[0-9]{11}$|^(77)[0-9]{11}$|^(88)[0-9]{11}$|^(99)[0-9]{11}$"
},
{
"code": "EMS",
"id": 2,
"name": "EMS",
"reg_mail_no": "^[A-Z]{2}[0-9]{9}[A-Z]{2}$|^(10|11|12)[0-9]{11}$|^(50|51)[0-9]{11}$|^(95|97)[0-9]{11}$"
},
{
"code": "YUNDA",
"id": 102,
"name": "韵达快递",
"reg_mail_no": "^(10|11|12|13|14|15|16|17|19|18|50|55|58|80|88|66|31|77|39)[0-9]{11}$|^[0-9]{13}$"
},
{
"code": "HTKY",
"id": 502,
"name": "极兔速递",
"reg_mail_no": "^((A|B|D|E)[0-9]{12})$|^(BXA[0-9]{10})$|^(K8[0-9]{11})$|^(02[0-9]{11})$|^(000[0-9]{10})$|^(C0000[0-9]{8})$|^((21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|61|63)[0-9]{10})$|^((50|51)[0-9]{12})$|^7[0-9]{13}$|^6[0-9]{13}$|^58[0-9]{14}$"
},
{
"code": "YTO",
"id": 101,
"name": "圆通速递",
"reg_mail_no": "^[A-Za-z0-9]{2}[0-9]{10}$|^[A-Za-z0-9]{2}[0-9]{8}$|^[6-9][0-9]{17}$|^[DD]{2}[8-9][0-9]{15}$|^[Y][0-9]{12}$"
},
{
"code": "TTKDEX",
"id": 504,
"name": "天天快递",
"reg_mail_no": "(66|77|88|(5(5|6|8)))\\d{10}|(99(5|8))\\d{9}|TT(66|88|99|(5(6|7)))\\d{11}"
},
{
"code": "QFKD",
"id": 1216,
"name": "全峰快递",
"reg_mail_no": "^[0-6|9][0-9]{11}$|^[7][0-8][0-9]{10}$|^[0-9]{15}$|^[S][0-9]{9,11}(-|)P[0-9]{1,2}$|^[0-9]{13}$|^[8][0,2-9][0,2-9][0-9]{9}$|^[8][1][0,2-9][0-9]{9}$|^[8][0,2-9][0-9]{10}$|^[8][1][1][0][8][9][0-9]{6}$"
},
{
"code": "EYB",
"id": 3,
"name": "EMS经济快递",
"reg_mail_no": "^[A-Z]{2}[0-9]{9}[A-Z]{2}$|^(10|11)[0-9]{11}$|^(50|51)[0-9]{11}$|^(95|97)[0-9]{11}$"
},
{
"code": "UC",
"id": 1207,
"name": "优速快递",
"reg_mail_no": "^VIP[0-9]{9}|V[0-9]{11}|[0-9]{12}$|^LBX[0-9]{15}-[2-9AZ]{1}-[1-9A-Z]{1}$|^(9001)[0-9]{8}$"
},
{
"code": "DBKD",
"id": 5000000110730,
"name": "德邦快递",
"reg_mail_no": "^[0-9]{8,10}$|^\\d{15,}[-\\d]+$"
},
{
"code": "SURE",
"id": 201174,
"name": "速尔快运",
"reg_mail_no": "^(SUR)[0-9]{12}$|^[0-9]{12}$"
},
{
"code": "FEDEX",
"id": 106,
"name": "联邦快递",
"reg_mail_no": "^[0-9]{12}$"
},
{
"code": "SHQ",
"id": 108,
"name": "华强物流",
"reg_mail_no": "^[A-Za-z0-9]*[0|2|4|6|8]$"
},
{
"code": "UAPEX",
"id": 1259,
"name": "全一快递",
"reg_mail_no": "^\\d{12}|\\d{11}$"
},
{
"code": "HOAU",
"id": 1191,
"name": "天地华宇",
"reg_mail_no": "^[A-Za-z0-9]{8,9}$"
},
{
"code": "BEST",
"id": 105,
"name": "百世物流",
"reg_mail_no": "^[0-9]{11,12}$"
},
{
"code": "LB",
"id": 1195,
"name": "龙邦速递",
"reg_mail_no": "^[0-9]{12}$|^LBX[0-9]{15}-[2-9AZ]{1}-[1-9A-Z]{1}$|^[0-9]{15}$|^[0-9]{15}-[1-9A-Z]{1}-[1-9A-Z]{1}$"
},
{
"code": "XB",
"id": 1186,
"name": "新邦物流",
"reg_mail_no": "^[0-9]{8}$|^[0-9]{10}$"
},
{
"code": "ZTO",
"id": 500,
"name": "中通快递",
"reg_mail_no": "^((010|768|765|778|779|719|828|618|680|518|688|880|660|805|988|628|205|717|718|728|738|761|762|763|701|757|751|359|358|100|200|118|128|689|738|528|852)[0-9]{9})$|^((5711|2008|2009|2010|2013)[0-9]{8})$|^((91|92|93|94|95|98|36|68|39|50|53|37)[0-9]{10})$|^(4)[0-9]{11}$|^(90)[0-9]{10}$|^(120)[0-9]{9}$|^(780)[0-9]{9}$|^(881)[0-9]{9}$|^(882|885)[0-9]{9}$|^(54|55|56)[0-9]{10}$|^(960)[0-9]{9}$|^(665|666)[0-9]{9}$|^(63)[0-9]{10}$|^(64)[0-9]{10}$|^(72)[0-9]{10}$|^2[1-9][0-9]{10}$"
},
{
"code": "GTO",
"id": 200143,
"name": "国通快递",
"reg_mail_no": "^(3(([0-6]|[8-9])\\d{8})|((2|4|5|6)\\d{9})|(7(?![0|1|2|3|4|5|7|8|9])\\d{9})|(8(?![2-9])\\d{9})|(2|4)\\d{11})$"
},
{
"code": "FAST",
"id": 1204,
"name": "快捷快递",
"reg_mail_no": "^(?!440)(?!510)(?!520)(?!5231)([0-9]{9,13})$|^(P330[0-9]{8})$|^(D[0-9]{11})$|^(319)[0-9]{11}$|^(56)[0-9]{10}$|^(536)[0-9]{9}$"
},
{
"code": "NEDA",
"id": 1192,
"name": "能达速递",
"reg_mail_no": "^((88|)[0-9]{10})$|^((1|2|3|5|)[0-9]{9})$|^(90000[0-9]{7})$"
},
{
"code": "BJRFD-001",
"id": 100034107,
"name": "如风达配送",
"reg_mail_no": "^[\\x21-\\x7e]{1,100}$"
},
{
"code": "XFWL",
"id": 202855,
"name": "信丰物流",
"reg_mail_no": "^130[0-9]{9}|13[7-9]{1}[0-9]{9}|18[8-9]{1}[0-9]{9}$"
},
{
"code": "GDEMS",
"id": 1269,
"name": "广东EMS",
"reg_mail_no": "^[a-zA-Z]{2}[0-9]{9}[a-zA-Z]{2}$"
},
{
"code": "POSTB",
"id": 200734,
"name": "邮政快递包裹",
"reg_mail_no": "^([GA]|[KQ]|[PH]){2}[0-9]{9}([2-5][0-9]|[1][1-9]|[6][0-5])$|^[99]{2}[0-9]{11}$|^[96]{2}[0-9]{11}$|^[98]{2}[0-9]{11}$"
},
{
"code": "DBL",
"id": 107,
"name": "德邦物流",
"reg_mail_no": "^[0-9]{8,10}$|^\\d{15,}[-\\d]+$"
},
{
"code": "YCT",
"id": 1185,
"name": "黑猫宅急便",
"reg_mail_no": "^[0-9]{12}$"
},
{
"code": "LTS",
"id": 1214,
"name": "联昊通",
"reg_mail_no": "^[0-9]{9,12}$"
},
{
"code": "ESB",
"id": 200740,
"name": "E速宝",
"reg_mail_no": "[0-9a-zA-Z-]{5,20}"
},
{
"code": "BESTQJT",
"id": 105031,
"name": "百世快运",
"reg_mail_no": ""
},
{
"code": "QRT",
"id": 1208,
"name": "增益速递",
"reg_mail_no": "^[0-9]{12,13}$"
},
{
"code": "DISTRIBUTOR_13460212",
"id": -1,
"name": "D速物流",
"reg_mail_no": "^[A-Za-z0-9-]{4,35}$"
},
{
"code": "DISTRIBUTOR_12017865",
"id": -1,
"name": "安能快运",
"reg_mail_no": "^[A-Za-z0-9-]{4,35}$"
}
],
"trace_id": ""
}
文档更新时间: 2023-08-24 01:01 作者:admin