电商四级地址邮编查询
根据街道行政区划信息查询邮编,支持两种查询方式(二选一):
-
按街道行政区划代码(
street_code)查询, 如果有传入street_code则优先于方式2 -
按省、市、区、街道名称查询
一、接口名称
-
接口名称:电商四级地址邮编查询
-
接口地址:
https://kf.fw199.com/gateway/addr/zipcode -
请求方式:
POST -
Content-Type:
application/x-www-form-urlencoded
二、请求参数
公共参数
| 参数名 | 类型 | 是否必需 | 说明 |
|---|---|---|---|
| appid | string | 必需 | 应用 appid |
| timestamp | string | 必需 | 时间戳(毫秒) |
| sign | string | 必需 | 参数签名 |
业务参数
| 参数名 | 类型 | 是否必需 | 说明 |
|---|---|---|---|
| op | string | 否 | 平台标识,默认 `1`。1:标准行政区/淘宝 |
| street_code | string | 条件必需 | 街道行政区划代码。传入时按街道 code 查询(方式一) |
| province | string | 条件必需 | 省。与 city、district、street 同时传入时按地址查询(方式二) |
| city | string | 条件必需 | 市 |
| district | string | 条件必需 | 区/县 |
| street | string | 条件必需 | 街道/乡镇名称 |
说明:
-
street_code与province+city+district+street二选一 -
同时传两类参数时,优先按
street_code查询 -
仅查询
level=4(街道/镇)记录
三、请求示例代码
Java
方式一按省市区街道查询
@Testpublic void addrZipcodeByAddress() throws Exception {
// 业务参数 Map<String, String> data = new HashMap(); data.put("appid", Config.AppId); Long timestamp = System.currentTimeMillis(); data.put("timestamp", timestamp.toString()); data.put("op", "1"); data.put("province", "湖北省"); data.put("city", "湖北省辖县"); data.put("district", "潜江市"); data.put("street", "杨市街道"); // 参数签名 data.put("sign", Utils.Sign(data, Config.AppSecret)); String result = doHttpRequest(apiUrl, data); System.out.println("result:" + result);}方式二按街道 code 查询
@Testpublic void addrZipcodeByStreetCode() throws Exception {
// 业务参数 Map<String, String> data = new HashMap(); data.put("appid", Config.AppId); Long timestamp = System.currentTimeMillis(); data.put("timestamp", timestamp.toString()); data.put("op", "1"); data.put("street_code", "429005001"); // 参数签名 data.put("sign", Utils.Sign(data, Config.AppSecret)); String result = doHttpRequest(apiUrl, data); System.out.println("result:" + result);}四、返回结果
说明:最外层 code 为 0 表示成功,非 0 为失败,最外层 message 会包含失败原因。
四(一)、成功示例
{ "code": 0, "message": "ok", "data": { "code": "429005001", "street": "园林街道", "province": "湖北省", "city": "湖北省辖县", "district": "潜江市", "level": 4, "level_type": "街道", "zip_code": 433199 }, "trace_id": "e2be3d8a-e006-4b5d-b680-4ca5cc266a1a"}四(二)、data 字段说明
| 字段名 | 类型 | 说明 |
|---|---|---|
| code | string | 街道行政区划代码 |
| street | string | 街道/乡镇名称 |
| province | string | 省 |
| city | string | 市 |
| district | string | 区/县 |
| level | number | 级别,固定为 4(街道/镇) |
| level_type | string | 节点类型,如街道、镇等 |
| zip_code | number | 邮编 |
四(三)、失败示例
{ "code": 2, "message": "请传街道 code,或同时传 province/city/district/street"}{ "code": 3, "message": "未找到对应街道邮编"}