|
I allow my users to enter their address all on one single line, or sometimes in multiple lines but not separated into address, city, state, zip fields. I need to be able to parse out the valid address data and then perform address validation. How can I do that with your LiveAddress API? |
|
Absolutely. Extracting a valid address from a freeform address string is easy and only requires a few additional address variations. Let's dive right into how to use our LiveAddress API to perform Single Line Address Processing. The minimum requirement to verify an address through our system is address and ZIP code. This is sent to our system in two fields: street - This is the street level address data including suite and apartment numbers. Basically everything that is not city/state/zip. This must always have a minimum of two components.
lastline - This is the city/state/zip code data. Lastline must always contain either a ZIP code or two components.
We will assume that the street data portion comes first and that the lastline data comes last. Let's look at the following example address:
Begin by creating the first permutation (or address variation) by breaking the string into two fields: street and lastline, working from right to left. The permutations can be generated on the fly, as needed, or in a batch before submitting to our API. On-the-fly: Generate the first permutation and submit. If the address fails, generate the next and try again. Repeat until a successful address is matched or there are no more permutations to try. If the address is a positive match, stop there. Batch: Generate and serialize all the possible permutation from the input data. Submit them to our API in sequence, stopping with the first positive match or if they all fail. Here are the permutations from the example address:
Since the street field must have at least two components to it there is no need to test further. Here are the results:
In the case of the example address, it only took three permutations to get a positive match for the address. That's pretty fast. The positive match with the most data will usually be the most correct answer. If you were to continue testing you would get two more passing results but they would have less address data than the first positive match. for example, the address 3214 North University is deliverable but no longer has the unit number attached to it. So, for best results, stop with the first positive match. The end result is that you allow your users to enter addresses in the way that is most convenient for them and you can still parse out valid delivery data and get it back from our system broken down into address component data. NOTE: While this is a very effective method, it should always be used in conjunction with user interaction to verify the results. Sometimes it even makes your service look more impressive if you are able to give multiple results (for increased accuracy). If using this method with our LIveAddress for Lists service, you will want to use the address that validates with the most amount of data in the "street" field. This will give you the best results. |
|
Since the LiveAddress API has been upgraded to support 100 addresses at once, you can now perform this operation in a single HTTP request. And with our new pricing, it comes at no extra expense to you. In other words, for the permutations that don't verify, you don't pay for them. You only buy the good, verifiable addresses. Update: PHP example of performing verification on a single-line address -- demonstrates submitting each permutation in the same batch so only a single request is performed. Update: Here's a rudimentary example of performing single-line address processing (SLAP) with jQuery. This has a few quirks because of JSONP limitations, but it's basically functional. Here's the fiddle for it where you can try it out right away. |
Follow this question
By Email:Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
- *italic* or _italic_
- **bold** or __bold__
- link:[text](http://url.com/ "title")
- image?
- numbered list: 1. Foo 2. Bar
- to add a line break simply add two spaces to where you would like the new line to be.
- basic HTML tags are also supported
Tags:
Asked: 09 Feb, 13:05
Seen: 296 times
Last updated: 15 May, 12:31