API 文档

立即开始使用我们易于使用的 API,按照示例学习如何使用它。




GET 获取远处的邮政编码

通过这个易于使用的端点,您将获得给定距离内的邮政编码列表。请求示例将返回唯一邮政编码列表、邮政编码的完整列表以及每个邮政编码的详细信息。

GET https://postalcodes.app/api/v1/?key=YOUR-APIKEY&distance=25&zipcode=10005&country=us

我们的 API 接受以公里(默认)或英里为单位的距离测量。

要将测量更改为公里,您必须将ms参数放在您的请求中:

GET https://postalcodes.app/api/v1/?key=YOUR-APIKEY&ms=km&distance=25&zipcode=10005&country=us

响应将如下所示:

{
   "query":{
      "code": "10005",
      "country": "US",
      "range": "25",
      "measure": ""
   },
   "results":{
       "range_codes_unique": ["07010", "07020", "07022", "07024", "07026", ...],
       "range_codes": ["07010", "07020", "07022", "07024", "07026", ...],
       "range_codes_details": [
          {
              "postal_code":"07010",
              "country_code":"US",
              "city":"Cliffside Park",
              "state":"New Jersey",
              "state_code":"NJ",
              "province":"Bergen",
              "province_code":"003"
          },
          {
              "postal_code":"07020",
              "country_code":"US",
              "city":"Edgewater",
              "state":"New Jersey",
              "state_code":"NJ",
              "province":"Bergen",
              "province_code":"003"
          },
          {
              "postal_code":"07022",
              "country_code":"US",
              "city":"Fairview",
              "state":"New Jersey",
              "state_code":"NJ",
              "province":"Bergen",
              "province_code":"003"
          },
          {
              "postal_code":"07024",
              "country_code":"US",
              "city":"Fort Lee",
              "state":"New Jersey",
              "state_code":"NJ",
              "province":"Bergen",
              "province_code":"003"
          },
          {
              "postal_code":"07026",
              "country_code":"US",
              "city":"Garfield",
              "state":"New Jersey",
              "state_code":"NJ",
              "province":"Bergen",
              "province_code":"003"
          },
           ...
       ],
   }
}

GET 获取邮政编码详细信息

以下示例将返回与搜索查询匹配的邮政编码的详细信息。

GET https://postalcodes.app/api/v1/?key=YOUR-APIKEY&zipcode=10005&country=us

响应将如下所示:

{
   "query":{
      "code": "10005",
      "country": "us",
      "range": "",
      "measure": ""
   },
   "results":{
       "range_codes_unique": ["10005"],
       "range_codes": ["10005"],
       "range_codes_details": [
          {
              "postal_code":"10005",
              "country_code":"US",
              "city":"New York",
              "state":"New York",
              "state_code":"NY",
              "province":"New York",
              "province_code":"061"
          }
       ],
   }
}

GET 获取自定义数据

您可以传递额外的参数以仅获取您需要的结果,只需在您的请求中fields

GET https://postalcodes.app/api/v1/?key=YOUR-APIKEY&fields=["range_codes_unique"]&distance=25&zipcode=10005&country=us

响应将如下所示:

{
   "query":{
      "code": "10005",
      "country": "US",
      "range": "25",
      "measure": ""
   },
   "results":{
       "range_codes_unique": ["07010", "07020", "07022", "07024", "07026", ...]
   }
}



立即开始免费使用我们的 API!

每天获得 240 个免费请求

+94 支持的国家

AD (安道尔)
AR (阿根廷)
AS (美属萨摩亚)
AT (奥地利)
AU (澳大利亚)
AX (奥兰群岛)
AZ (阿塞拜疆)
BD (孟加拉国)
BE (比利时)
BG (保加利亚)
BM (百慕大)
BR (巴西)
Flag of Belarus
BY (白俄罗斯)
CA (加拿大)
CH (瑞士)
CL (智利)
CO (哥伦比亚)
CR (哥斯达黎加)
CY (塞浦路斯)
CZ (捷克共和国)
Flag of Germany
DE (德国)
DK (丹麦)
DO (多明尼加共和国)
DZ (阿尔及利亚)
EE (爱沙尼亚)
ES (西班牙)
FI (芬兰)
FM (密克罗尼西亚)
FO (法罗群岛)
FR (法国)
GB (英国)
GF (法属圭亚那)
GG (根西岛和奥尔德尼)
GL (格陵兰)
GP (瓜德罗普岛)
GT (危地马拉)
GU (关岛)
HR (克罗地亚(Hrvatska))
HU (匈牙利)
IE (爱尔兰)
IM (人(小岛))
IN (印度)
IS (冰岛)
IT (意大利)
JE (新泽西)
JP (日本)
Flag of South Korea
KR (韩国南部)
LI (列支敦士登)
LK (斯里兰卡)
LT (立陶宛)
LU (卢森堡)
LV (拉脱维亚)
MC (摩纳哥)
MD (摩尔多瓦)
Flag of the Marshall Islands
MH (马绍尔群岛)
MK (马其顿)
MP (北马里亚纳群岛)
MQ (马提尼克)
MT (马耳他)
Flag of Malawi
MW (马拉维)