主动提交查询请求,实时返回物流信息;即时获取最新状态,稳定高效。支持全球1000+快递公司。
无参数
无参数
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
secret_key | string | true | 用户授权key |
secret_code | string | true | 接口编号 |
secret_sign | string | true | 加密签名:md5(secret_key+secret_secret)转大写 |
param | string | true | 示例为:{"com":"yuantong","num":"yt2016025166944","from":"","phone":"","to":"","resultv2":0,"show":"0","order":"desc"} |
curl http://cloud.kuaidi100.com/api -X POST -d \
"secret_key=***&secret_code=c3e50f627ff6452ba44688ba8883f2dc&secret_sign=md5(***)¶m="
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
public class CloudDemo {
public static void main (String[] args) {
CloudDemo cloudDemo = new CloudDemo();
Map params = new HashMap();
params.put("secret_key", "***");
params.put("secret_code", "c3e50f627ff6452ba44688ba8883f2dc");
params.put("secret_sign", "md5(***)");
params.put("param", "");
cloudDemo.post(params);
}
public String post(Map params) {
StringBuilder response = new StringBuilder("");
BufferedReader reader = null;
try {
StringBuilder builder = new StringBuilder();
for (Map.Entry param : params.entrySet()) {
if (builder.length() > 0) {
builder.append('&');
}
builder.append(URLEncoder.encode(param.getKey(), "UTF-8"));
builder.append('=');
builder.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
}
byte[] bytes = builder.toString().getBytes("UTF-8");
URL url = new URL("http://cloud.kuaidi100.com/api");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
conn.setRequestMethod("POST");
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(bytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(bytes);
reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line = "";
while ((line = reader.readLine()) != null) {
response.append(line);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != reader) {
reader.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return response.toString();
}
}
class MD5Utils { private static MessageDigest mdigest = null;
private static char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
private static MessageDigest getMdInst() {
if (null == mdigest) {
try {
mdigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
return mdigest;
}
public static String encode(String s) {
if(null == s) {
return "";
}
try { byte[] bytes = s.getBytes();
getMdInst().update(bytes);
byte[] md = getMdInst().digest();
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for(int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = digits[byte0 >>> 4 & 0xf];
str[k++] = digits[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
暂无示例
<?php
$params = "";
$params .= 'secret_key=***'.'&';
$params .= 'secret_code=c3e50f627ff6452ba44688ba8883f2dc'.'&';
$params .= 'secret_sign=md5(***)'.'&';
$params .= 'param='.'&';
$params .= substr($params, 0, -1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, 'http://cloud.kuaidi100.com/api');
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
echo $result;
?>
# coding = utf-8
import sys,os
import requests,json,hashlib
params = {}
params['secret_key'] = '***'
params['secret_code'] = 'c3e50f627ff6452ba44688ba8883f2dc'
params['secret_sign'] = 'md5(***)'
params['param'] = ''
result = requests.post('http://cloud.kuaidi100.com/api', params)
print(result.text)
无参数
{
"message":"ok",
"state":"0", //快递单当前状态,包括0在途,1揽收,2疑难,3签收,4退签,5派件,6退回,7转投 等8个状态
"status":"200",
"condition":"F00",
"ischeck":"0", //是否签收标记
"com":"yuantong", //快递公司编码,
"nu":"V030344422", //快递单号
"data":[ //数组,包含多个对象
{
"context":"上海分拨中心/装件入车扫描 ", //物流轨迹节点内容
"time":"2012-08-28 16:33:19", //时间,原始格式
"ftime":"2012-08-28 16:33:19", //格式化后时间
},
{
"context":"上海分拨中心/下车扫描 ",
"time":"2012-08-27 23:22:42",
"ftime":"2012-08-27 23:22:42",
}]
}
{
"message":"ok",
"state":"0",
"status":"400",
}
状态码 | 状态码信息 | 描述 |
---|---|---|
200 | ok | 成功 |
实时快递查询支持主动提交查询请求,实时返回物流信息;
即时获取最新状态,稳定高效。
支持全球1000+快递公司。
参数名称 | 是否必填 | 示例值 | 参数描述 |
---|---|---|---|
com | 必须 | ems | 查询的快递公司的编码,一律用小写字母 |
num | 必须 | EM263999513JP | 查询的快递单号, 单号的最大长度是32个字符 |
phone | 可选 | 13868688888 | 收件人或寄件人的手机号或固话(顺丰单号必填,也可以填写后四位,如果是固话,请不要上传分机号) |
from | 可选 | 广东省深圳市南山区 | 出发地城市,省-市-区 |
to | 可选 | 北京市朝阳区 | 目的地城市,省-市-区 |
resultv2 | 可选 | 1 | 添加此字段表示开通行政区域解析功能。0:关闭(默认),1:开通行政区域解析功能,2:开通行政解析功能并且返回出发、目的及当前城市信息 |
show | 可选 | 0 | 返回数据格式。0:json(默认),1:xml,2:html,3:text |
order | 可选 | desc | 返回结果排序方式。desc:降序(默认),asc:升序 |
参数中的快递公司请使用该表对应的编码
快递公司编码表:
http://api.kuaidi100.com/manager/openapi/download/kdbm.do