USPS does require that you register with them before you can use the API, but, as far as I could tell, there is no charge for access. By the way, their API has some other features: you can do Address Standardization and Zip Code Lookup, as well as the whole suite of tracking, shipping, labels, etc.
I've seen zip code databases that can be purchased. Address correction services are available through major shippers like UPS, FedEx and the USPS, but I don't know if those services are free.
I know I'm late but hopefully this will still help people.
Remember a zip code is a US Postal Service delivery area. It doesn't respect any boundaries (except that it doesn't ever cross countries). Zipcodes frequently cross city, county, and even state lines. They exist for the convenience of the US Postal Service. Looking for one single zipcode based on a city+state is going to give you the zipcode that is the default for that city+state. In a rural area, that's great, but if I ask "what is the zipcode for New York, NY?" the response of a single zipcode won't be any help at all for me. As mentioned in other answers, you need an address AND city+state to accurately determine the delivery route, or the zipcode.
For some reason it seems to be really hard to find an up to date list of US zipcodes. I guess that baffles me because I always have one readily available. Here's the current one. It includes all 42,000+ zipcodes and also all of the city/state variations that are acceptable by the US Postal Service for those zipcodes.
发布评论
评论(6)
有一个 API 可以实现这一点。
http://developer.yahoo.com/maps/rest/V1/geocode.html
There's an API for that.
http://developer.yahoo.com/maps/rest/V1/geocode.html
这是一个免费的库,您可以在本地下载和使用,而无需依赖第三方 API:
http:// /zips.sourceforge.net/
This is a free library that you can download and use locally, without having to rely on a third-party API:
http://zips.sourceforge.net/
使用美国邮政服务 HTTP/XML API
您可以根据美国邮政上的此页面 记录其基于 XML 的 Web API 的服务网站,特别是 此 PDF 文档,他们有一个 URL,您可以在其中发送包含地址减去邮政编码的 XML 请求,他们将使用包含完整地址的 XML 文档进行响应。
根据他们的文档,您将发送以下内容:
以下是您将收到的返回内容:
USPS 确实要求您在使用 API 之前向他们注册,但是,据我所知,访问无需付费。顺便说一句,他们的 API 还有一些其他功能:您可以进行地址标准化和邮政编码查找,以及整套跟踪、运输、标签等。
You can use the US Postal Service HTTP/XML API
According to this page on the US Postal Service website which documents their XML based web API, specifically Section 3.0 (page 13) of this PDF document, they have a URL where you can send an XML request containing an address minus the Zip Code and they will respond with an XML document containing the complete address.
According to their documentation, here's what you would send:
And here's what you would receive back:
USPS does require that you register with them before you can use the API, but, as far as I could tell, there is no charge for access. By the way, their API has some other features: you can do Address Standardization and Zip Code Lookup, as well as the whole suite of tracking, shipping, labels, etc.
我见过可以购买的邮政编码数据库。地址更正服务可通过 UPS、FedEx 和 USPS,但我不知道这些服务是否免费。
I've seen zip code databases that can be purchased. Address correction services are available through major shippers like UPS, FedEx and the USPS, but I don't know if those services are free.
我知道我迟到了,但希望这仍然可以帮助人们。
请记住,邮政编码是美国邮政服务的投递区域。它不尊重任何边界(除了它不跨越国家)。邮政编码经常跨越城市、县甚至州界线。它们的存在是为了方便美国邮政服务。查找基于城市+州的单个邮政编码将为您提供该城市+州的默认邮政编码。在农村地区,这很好,但如果我问“纽约州纽约市的邮政编码是什么?”单个邮政编码的响应对我来说根本没有任何帮助。正如其他答案中提到的,您需要一个地址和城市+州才能准确确定送货路线或邮政编码。
由于某种原因,似乎很难找到最新的美国邮政编码列表。我想这让我感到困惑,因为我总是有一个随时可用的。这是当前的一个。它包括所有 42,000 多个邮政编码以及美国邮政服务可接受的这些邮政编码的所有城市/州变体。
https://www.dropbox.com/s/xa39nv6pcmy8z3d/ zipcodes-Aug2017.zip?dl=0
我每天在一家名为 SmartyStreets 的公司处理地址。
I know I'm late but hopefully this will still help people.
Remember a zip code is a US Postal Service delivery area. It doesn't respect any boundaries (except that it doesn't ever cross countries). Zipcodes frequently cross city, county, and even state lines. They exist for the convenience of the US Postal Service. Looking for one single zipcode based on a city+state is going to give you the zipcode that is the default for that city+state. In a rural area, that's great, but if I ask "what is the zipcode for New York, NY?" the response of a single zipcode won't be any help at all for me. As mentioned in other answers, you need an address AND city+state to accurately determine the delivery route, or the zipcode.
For some reason it seems to be really hard to find an up to date list of US zipcodes. I guess that baffles me because I always have one readily available. Here's the current one. It includes all 42,000+ zipcodes and also all of the city/state variations that are acceptable by the US Postal Service for those zipcodes.
https://www.dropbox.com/s/xa39nv6pcmy8z3d/zipcodes-Aug2017.zip?dl=0
I work with addresses everyday at a company called SmartyStreets.
有关此问题的最新答案,请查看 AggData.com 的 “美国邮政编码完整列表”代码”(许可证),其数据来自 GeoNames,在 知识共享归属 4.0 许可证。
For a more up-to-date answer on this, look into AggData.com’s "Complete List of United States Zip Codes" (License), which derives its data from GeoNames, a work published under the Creative Commons Attribution 4.0 License.