通过这个易于使用的端点,您将获得给定距离内的邮政编码列表。请求示例将返回唯一邮政编码列表、邮政编码的完整列表以及每个邮政编码的详细信息。
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 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"
}
],
}
}
您可以传递额外的参数以仅获取您需要的结果,只需在您的请求中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", ...]
}
}