CanadaPost does this in their website through their systems. I tried submitting an AJAX POST request to their servers, but after inspecting the POST request that is sent using their website, I realized that they send the postal code and other special variables.
Greg, mentions a good point, but may not be possible if you only know the postal code. On the flip side, a street can have many postal codes as well and not necessary have the same first half for all of them (think of really long streets).
You can use Curl to post a postal code to 'find an address' and get a listing of results to parse through. Make sure you pass appropriate fields to the page though (ie. hidden fields from form submission page).
Marcel is correct in his comments. By their very nature, postal codes (in most countries that I know of, at least) are bounded regions in which are usually many streets, sometimes other political boundaries, too.
I'm curious how the Canada Post website is able to magically know the street name from a single postal code. Where is the interface located (URL)? What data are you passing in, and what other variables is it sending? Posting these things will make it easier to answer your question more directly.
I work at SmartyStreets where we perform US and international address validation. From what I know, as narrow as you can get with only a postal code is maybe a city block, floor of a building, or corporation (if it's a unique/custom postal code) -- that's if you have the fully-expanded postal code (in the US, it's called ZIP+4). Canadian post might be different, though.
edit: another thing to note is that CASS will still clean up addresses without finding the correct address in the database. so, Drive = DR, Street = ST, etc, but it might not actually exist. - Check for AS01 or AS02 in the CASS_Results field to see that it has been verified.
It depends upon how easily you want to grab the data. The USPS appears to have a "free" service for lookups. I'd write a macro that performs the lookup. I'd find other solutions potentially more work than just going to the post office and getting their answer.
The terms of use state that the data must be used for shipping. I'm no lawyer, but if you are ever planning on mailing to these addresses, then it sounds reasonable to use the API and create mailable addresses with the ZIP. Read for yourself and see if this helps you. What's your take?
the only problem i've encountered with the API is that it can be slow when trying to certify a large volume of addresses. The CASS tool is threaded and can push through a much as your computer can handle without major limitations. The API will be throttled and have plenty of latency to drive the process into the ground.
I believe CASSing only standardizes the address. Meaning "Street" becomes "St" and that sort of thing. If it can find the address using the zip code, then it will add in delivery point and a bunch of other data points. But if there is no zip, then unless the address is a zip in and of itself (some post offices have their own zip), you're not going to get zips.
Can you provide a small sample of a few addresses? I am able to generate ZIP codes (and even ZIP+4) for addresses missing them entirely - however I know these addresses to be correct before loading them into the CASS tool.
My guess is that CASS is attempting to fix other issues with the address quality first. What are the codes you are getting in the CASS_Results fields? if it references AS01 or AS02 in there then it should be able to generate a ZIP code.
Ah yes - when I try addresses (number, street, city, state) that I too know are 100% accurate, it will return the zip and other fields. For a bunch of our client addresses that must not be accurate, CASS will not return any other data points (error code = Z, "Invalid ZIP/Postal Code"), but the geocoder will.
The first thing I noticed was my city field was full of fluff, so CASS couldn't match that. I'm simply going to update that field with the actual city names (I bizarrely have codes in there) and see where that gets me.
In the United States of America a zipcode is five or nine numbers that are added to a postal address to assist the sorting of mail. There are currently about 43,000 zipcode. This tool can also find the postal code of many other countries. Postal codes vary from one country to another but they are usually a group of numbers between 3 and 10 digits long. In some countries such as the United Kingdom and Canada, postal code are comprised of number and letters.
Map data and other geolocation information, including exact locations, can vary across data providers. As a best practice, use the same data provider for your place index, map, and other Amazon Location resources. For example, if the places returned by your place index do not match the location of the same places provided by your map resource, you can place a marker in what appears to be the wrong location on the map.
You can then integrate monitoring using services such as Amazon CloudWatch and AWS CloudTrail. For more information see, Monitoring Amazon Location Service with Amazon CloudWatch and Logging and monitoring with AWS CloudTrail.
Amazon Location Service also provides a reverse geocoding action called SearchPlaceIndexForPosition. This takes a geographic location and returns the address, business, or other information about what is at that location.
When you make a successful search request in Amazon Location Service, one or more results are returned. Each result includes a label, which is the name or description of the result. For example, a search for coffee shop, might return a result with the label Hometown Cafe, telling you that a coffee shop called "Hometown Cafe" was found. The search result will also typically include a structured address (with properties such as the address number, unit, street, and postal code). Depending on the data provider, it will include other meta data, as well, such as the country and time zone.
For a search on a business name or category (such as coffee shop), you might want to show all returned results on a map. For an address search, you might want to just use the first result automatically. See the next topic for information about relevance.
When searching by text, Amazon Location Service will often find more than a single result. For example, a search for Paris may return the city in France, but also the city in Texas. The results are sorted by the relevance, as determined by the data provider.
Results are returned in relevance order from all providers. If you choose Esri or Grab as your data provider, the results include a relevance value that you can use to understand the relative relevance between the results of a single request.
Specifying additional information, such as a country name, or a location to search around, can change the order of results, reduce the number of results, or even change the set of results returned. For example, a search for Paris with a location in Texas to search around is more likely to return Paris, Texas as the first result than Paris, France.
In an interactive application, you can use relevance to help decide whether to accept the top result, or to ask a user to disambiguate between multiple returned results. If the first result has a high relevance, you might just accept it as the correct answer. If there are multiple high relevance results, or no high relevance results, you might want to list the results and let the user select the best result.
You can search for addresses with Amazon Location Service using the same SearchPlaceIndexForText action. The more information that you provide, the more likely the address returned will match the one given. For example, 123 Main St is less likely to find a correct result than 123 Main St, Anytown, California, 90210.
Addresses have multiple attributes, such as the street number, street, city, region, and postal code, etc. Those attributes are used to find an address in the place index that matches as many aspects as possible. The more attributes found, the more relevant the match is considered, and the more likely it will be returned.
The relevance for address results is based on how closely the result matches the input. This could be the number of the attributes that matched, but also how closely the results match the input. For example, an input of 123 Main St would have a higher relevance when Main St is found in the data, than if Maine St is the only result. Maine St will still be returned, but likely with a lower relevance value.
The search results include a label for the full address (123 Main St, Anytown, California, 90210), but also the individual structured attributes of the returned address. This is helpful, because you can use that, for example, to populate address fields in a database, or to examine the results and find the city, region, or postal code of the found location.
The data provider creates the geolocation data with those two known addresses. You can search for those two addresses, and they are found. After the data provider creates the map data, let's suppose that a new house is added, between the first two addresses. This new house is given the address 230. If you search for 230 S 9th St, the data provider will still find a result. Instead of using a known address, it will interpolate between the already known addresses, and estimate the position of the new address from those. In this case, it might assume that 230 is halfway between 220 and 240 (and on the same side of the street), and return an approximate location based on that.
Data providers periodically update their geolocation data with new addresses. In this case, 230 S 9th St would get added to the data provider data, but there will typically be a period when a new address has been created but is not yet added to the data.
In this case, the data provider can't tell whether the new address exists in the world, as it is not yet in the data, but provides the best answer it can from the information it has. This result is called interpolated, and can be returned by the data provider in the results. If interpolated returns false, it is a known address. If it returns true, it's an approximated address. If it's not returned, then the data provider did not provide the information about whether the result came from interpolation.
3a8082e126