在数字化时代,物流行业迎来了全新的变革和机遇。全国快递物流查询API作为一项创新技术,正在引领着物流业的数字化转型和智能化革新。
本文将提供各种快递查询 API的接入Java代码,有需要的小伙伴自取~
实时快递查询
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{"cpCode":"YTO","mailNo":"YTO1111111111","tel":"13000000000或0000","orderType":"asc"}");
Request request = new Request.Builder()
.url("https://eolink.o.apispace.com/wlgj1/paidtobuy_api/trace_search")
.method("POST",body)
.addHeader("X-APISpace-Token","API_KEY") // API_KEY 需要替换为APISpace 提供的API 密钥
.addHeader("Authorization-Type","apikey")
.addHeader("Content-Type","application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
注意:API_KEY 到 APISpace 登录获取即可。
快递批量实时查询
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{"data":[{"cpCode":"YTO","mailNo":"YTO1111111111","tel":"13000000000或0000"}],"cpCode":"YTO","mailNo":"YTO1111111111","tel":"13000000000或0000"}");
Request request = new Request.Builder()
.url("https://eolink.o.apispace.com/wlgj1/paidtobuy_api/trace_batch_search")
.method("POST",body)
.addHeader("X-APISpace-Token","API_KEY") // API_KEY 需要替换为APISpace 提供的API 密钥
.addHeader("Authorization-Type","apikey")
.addHeader("Content-Type","application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
识别电子面单号(免费)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{"mailNo":"YTO1111111111"}");
Request request = new Request.Builder()
.url("https://eolink.o.apispace.com/wlgj1/paidtobuy_api/mail_discern")
.method("POST",body)
.addHeader("X-APISpace-Token","API_KEY") // API_KEY 需要替换为APISpace 提供的API 密钥
.addHeader("Authorization-Type","apikey")
.addHeader("Content-Type","application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
物流轨迹地图获取
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{"cpCode":"YTO","mailNo":"YTO1111111111","phone":"1300000000","origin":"浙江省杭州市滨江区","destination":"浙江省杭州市滨江区","receiveAddress":"江南大道","responseModel":"H5"}");
Request request = new Request.Builder()
.url("https://eolink.o.apispace.com/wldtgj1/paidtobuy_api/trace_map")
.method("POST",body)
.addHeader("X-APISpace-Token","API_KEY") // API_KEY 需要替换为APISpace 提供的API 密钥
.addHeader("Authorization-Type","apikey")
.addHeader("Content-Type","application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
物流订阅与推送
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{"cpCode":"","mailNo":"","phone":"","callBackUrl":""}");
Request request = new Request.Builder()
.url("https://eolink.o.apispace.com/wldtgj1/paidtobuy_api/trace_subscribe")
.method("POST",body)
.addHeader("X-APISpace-Token","API_KEY") // API_KEY 需要替换为APISpace 提供的API 密钥
.addHeader("Authorization-Type","apikey")
.addHeader("Content-Type","application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
国际物流订阅
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{"cpCode":"","mailNo":""}");
Request request = new Request.Builder()
.url("https://eolink.o.apispace.com/internationallogistics/subscribe")
.method("POST",body)
.addHeader("X-APISpace-Token","API_KEY") // API_KEY 需要替换为APISpace 提供的API 密钥
.addHeader("Authorization-Type","apikey")
.addHeader("Content-Type","")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
国际物流查询
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{"cpCode":"","mailNo":""}");
Request request = new Request.Builder()
.url("https://eolink.o.apispace.com/internationallogistics/trace")
.method("POST",body)
.addHeader("X-APISpace-Token","API_KEY") // API_KEY 需要替换为APISpace 提供的API 密钥
.addHeader("Authorization-Type","apikey")
.addHeader("Content-Type","")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
快递可达校验
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{"cpCode":"YTO","province":"广东省","city":"东莞市","country":"","town":"大朗镇","address":"杨新路82号"}");
Request request = new Request.Builder()
.url("https://eolink.o.apispace.com/kdkdjy1/paidtobuy_api/address_reachable")
.method("POST",body)
.addHeader("X-APISpace-Token","API_KEY") // API_KEY 需要替换为APISpace 提供的API 密钥
.addHeader("Authorization-Type","apikey")
.addHeader("Content-Type","application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
物流时效性查询
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{"sendProvince":"","sendCity":"","sendDistrict":"","recvProvince":"","recvCity":"","recvDistrict":""}");
Request request = new Request.Builder()
.url("https://eolink.o.apispace.com/logisticstimeliness/get")
.method("POST",body)
.addHeader("X-APISpace-Token","API_KEY") // API_KEY 需要替换为APISpace 提供的API 密钥
.addHeader("Authorization-Type","apikey")
.addHeader("Content-Type","application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
写在最后
如果需要其他开发语言的小伙伴,欢迎评论区留言~