You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于HERE autocomplete API查询英国地址返回短邮政编码的问题

HERE Autocomplete API英国地址查询邮编截断问题解决办法

问题概述

使用HERE Autocomplete API查询英国的街道+门牌号地址时,返回的邮政编码会缺失最后两位(单元相关字符)。比如查询"Choyce Close 38",API返回邮编LE67 3,但实际完整邮编应为LE67 3SS;而直接查询完整邮编时,API能返回正确的地址信息。

街道+门牌号查询请求与响应

请求:

GET https://autocomplete.search.hereapi.com/v1/autocomplete?apiKey=&q=choyce%20close%2038&lang=en&limit=1

响应:

{
    "items": [
        {
            "title": "United Kingdom, LE67 3, Coalville, 38 Choyce Close",
            "id": "here:af:streetsection:E77KSGCrId.g46fwNvmTSC:CggIBCDom-OxAxABGgIzOA",
            "language": "en",
            "resultType": "houseNumber",
            "address": {
                "label": "38 Choyce Close, Coalville, LE67 3, United Kingdom",
                "countryCode": "GBR",
                "countryName": "United Kingdom",
                "state": "England",
                "county": "Leicestershire",
                "city": "Coalville",
                "street": "Choyce Close",
                "postalCode": "LE67 3",
                "houseNumber": "38"
            },
            "highlights": {
                "title": [
                    {
                        "start": 35,
                        "end": 37
                    },
                    {
                        "start": 38,
                        "end": 50
                    }
                ],
                "address": {
                    "label": [
                        {
                            "start": 0,
                            "end": 2
                        },
                        {
                            "start": 3,
                            "end": 15
                        }
                    ],
                    "street": [
                        {
                            "start": 0,
                            "end": 12
                        }
                    ],
                    "houseNumber": [
                        {
                            "start": 0,
                            "end": 2
                        }
                    ]
                }
            }
        }
    ]
}

完整邮编查询请求与响应

请求:

GET https://autocomplete.search.hereapi.com/v1/autocomplete?apiKey=&q=LE67%203SS&lang=en&limit=1

响应:

{
    "items": [
        {
            "title": "United Kingdom, Coalville, LE67 3SS Choyce Close",
            "id": "here:af:streetsection:E77KSGCrId.g46fwNvmTSC:EAMyCGxlNjd8M3Nz",
            "language": "en",
            "resultType": "postalCodePoint",
            "address": {
                "label": "LE67 3SS Choyce Close, Coalville, United Kingdom",
                "countryCode": "GBR",
                "countryName": "United Kingdom",
                "state": "England",
                "county": "Leicestershire",
                "city": "Coalville",
                "street": "Choyce Close",
                "postalCode": "LE67 3SS"
            },
            "highlights": {
                "title": [
                    {
                        "start": 27,
                        "end": 35
                    }
                ],
                "address": {
                    "label": [
                        {
                            "start": 0,
                            "end": 8
                        }
                    ],
                    "postalCode": [
                        {
                            "start": 0,
                            "end": 8
                        }
                    ]
                }
            }
        }
    ]
}

解决方案

Autocomplete API的定位是地址候选提示,返回的是精简信息,因此针对街道+门牌号的查询仅会返回街道级别的邮编前缀。要获取完整的单元级邮编,需配合HERE的Geocode Lookup API完成二次查询:

  1. 调用Autocomplete API获取目标地址的id字段(如示例中的here:af:streetsection:E77KSGCrId.g46fwNvmTSC:CggIBCDom-OxAxABGgIzOA)
  2. 将该id传入Geocode Lookup API,获取包含完整邮编的详细地址数据

示例Lookup请求:

GET https://geocode.search.hereapi.com/v1/lookup?apiKey=YOUR_API_KEY&id=here:af:streetsection:E77KSGCrId.g46fwNvmTSC:CggIBCDom-OxAxABGgIzOA

通过这个接口就能拿到包含完整邮政编码的地址详情,满足查询街道+门牌号时获取完整邮编的需求。

内容的提问来源于stack exchange,提问作者Andy Moe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 22:02:46