tags:

views:

251

answers:

12

U.K. that require addresses often ask the user to provide a postcode. The site then offers the user a choice between the addresses that match that postcode.

Where do these sites get the data to do this? Are there webservices that match postcodes to addresses? Do sites buy a database of addresses that they then query locally?

+3  A: 

You can use a geocoding service, such as the one provided by Google.

http://stackoverflow.com/questions/1363177/physical-address-to-geolocation-uk

davek
+8  A: 

I believe you need the Royal Mail Postcode Address File. From that link:

PAF is the only complete source of all known UK Postcodes.

Services do exist to handle requests for this info, such that it may be cheaper to use such services for small numbers of requests (obviously you have issues as and when such services aren't available for whatever reasons).

Brian Agnew
An outdated copy of the PAF was leaked: http://wikileaks.org/wiki/UK_government_database_of_all_1,841,177_post_codes_together_with_precise_geographic_coordinates_and_other_information,_8_Jul_2009Use at your own peril.
invariant
Marko Carter
you don't need the PAF. Depending on your traffic, signing up to a commercial vendor that charge on a per-request basis could be much cheaper (and saves you the hassle of building your lookup infrastructure)
Richard
@Richard - noted. Answer amended
Brian Agnew
+4  A: 

To do this you need access to the Postcode Address File - this is something that is licensed for use on an annual basis from the post-office, usually via a third party.

You have a choice depending on your needs of buying a package to use locally or of using web services.

The Royal Mail's page is here: http://www.royalmail.com/portal/rm/jump2?mediaId=400085&catId=400084 and on that page are links to service providers.

Murph
+7  A: 

The only way to do it officially up to now has been to buy the Postcode Address File however there was a news item recently that the data may be free in 2010 so depends if you can wait!

jbloomer
or maybe now: http://www.theregister.co.uk/2009/12/10/ordnance_survey_data_postcode_paf/
Jim
and this more recent article in the Register (http://www.theregister.co.uk/2010/03/17/ordnance_consultation_survey_deadline) claims:"The Beeb wrongly interpreted that as suggesting that UK.gov was about to wrestle the PAF database from the hands of Royal Mail bosses, who pulled in £1.6m in licensing fees for the service in 2007.However, as we reported, neither the Royal Mail - nor indeed the government - ever had any intentions of freeing up the PAF database for all comers."... sadly ...
hawbsl
+1  A: 

They could be using Experian QAS.

Bob Moore
+1  A: 

You can either use the PAF or one of the commercial web services (there are a few) which licence the PAF. I think you usually buy "credits" or pay a flat rate for unlimited access.

dsas
+3  A: 

Postcode Anywhere is one of the providers out there (one of my clients uses them with no complaints). Licensing is flexible: Postcode Anywhere UK Address Finder

Ben Poole
I've used these guys, easy to use API, no complaints either
JonoW
+1  A: 

try this http://www.afd.co.uk/

+1  A: 

To add to the answers already coming through:

In the paid for products typically you pay for either:

  • premise level - more detailed and can offer the user a list of premises at that postcode location

  • street level - simply matches the street at that postcode location - you or your user fills in "the first line of the address" usually house name or number

I believe this differentiation is built into the licencing by the Royal Mail at source. Premise level is substantially more expensive

hawbsl
+3  A: 

Contrary to the answers here, you do NOT need the very expensive PAF from the Post Office. There are a number of commercial services (presumably powered by the PAF) that return the streets and street numbers for a specified post code. They generally charged on a per-request basis. I do not have any experience with a particular vendor, but this is an example - capscan

Richard
You don't need to buy the PAF from the post office, you need to be able to *access* data *from* the PAF - a subtle but important distinction but when all is said and done, however you get to it, that's the source of the data.
Murph
A: 

If you're adding it into a website shopping cart or similar system, you can buy access to the data on a per-click basis. If you're using it for an internal system such as CRM, you need to buy a per-user license.

Either way, you can use the Data8 Postcode Lookup API via web services.

MarkC
A: 

If you want to get the approximate address for a UK postcode (i.e. street level) there is a way you can do it legally and for free without using PAF data.

  1. Geocode the postcode - This can be done legally for free now. OS have released the codepoint database into the public domain
  2. Do a reverse lookup on the WGS84 lat/lng pair using the Google Maps HTTP Geocoding API to get the street address

As an example of this take a look at this XML Web Service:

http://geo.jamiethompson.co.uk/W127RJ.xml

explained at:

http://jamiethompson.co.uk/projects/2010/04/30/an-open-free-uk-postcode-geocoding-web-service/

which returns:

<result>
    <status>200</status>
    <message/>
    <postcode>W12 7RJ</postcode>
    <geo>
        <os_x>523180</os_x>
        <os_y>180541</os_y>
        <lat>51.510379</lat>
        <lng>-0.226376</lng>
        <landranger>TQ231805</landranger>
        <accuracy>1</accuracy>
        <key>UO1NV-4UO8</key>
    </geo>
<address>
    <street>White City Close</street>
    <locality>Hammersmith</locality>
    <district>Hammersmith</district>
    <county>Greater London</county>
</address>

It's not as handy as the commercial offerings which give you a full list of actual addresses for any given postcode, but it lets you do a "What's your postcode? What's your house number?" type system.

WibblePoop