jaymc Posted June 3, 2010 Share Posted June 3, 2010 Does anyone know of a free API to lookup a UK postcode and return street, city, town etc.. Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/ Share on other sites More sharing options...
zq29 Posted June 3, 2010 Share Posted June 3, 2010 You'd be lucky as that information is copy-written and owned by the Royal Mail, whoever would be providing it would be breaking their license agreement. You might be able to do some approximate searches with one of Googles APIs, but it probably won't be as accurate as you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/#findComment-1067409 Share on other sites More sharing options...
JonnoTheDev Posted June 4, 2010 Share Posted June 4, 2010 You'd be lucky as that information is copy-written and owned by the Royal Mail, whoever would be providing it would be breaking their license agreement. You might be able to do some approximate searches with one of Googles APIs, but it probably won't be as accurate as you are looking for. The Royal Mail database will soon be open source as part of government legislation. It was set to be open as of April this year, however I have not checked it out. http://news.bbc.co.uk/1/hi/technology/8402327.stm I recently went to a conference where the following were doing a presentation on using postcode data. It is a paid service, but check it out. I have used before and it's easy to implement. http://www.postcodeanywhere.co.uk/ Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/#findComment-1067581 Share on other sites More sharing options...
zq29 Posted June 4, 2010 Share Posted June 4, 2010 I heave read things every so often about them opening up the PAF, but it never materializes. I wouldn't hold your breath. Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/#findComment-1067591 Share on other sites More sharing options...
JonnoTheDev Posted June 4, 2010 Share Posted June 4, 2010 I heave read things every so often about them opening up the PAF, but it never materializes. I wouldn't hold your breath. I was speaking to a rep from RM last week. The data will be released. I think they are still working on how to make it accessible. Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/#findComment-1067606 Share on other sites More sharing options...
cags Posted June 4, 2010 Share Posted June 4, 2010 Which is going to take weeks at best, but most likely months and it's possible it could be years. I certainly won't be holding my breath that long. Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/#findComment-1067609 Share on other sites More sharing options...
zq29 Posted June 4, 2010 Share Posted June 4, 2010 I heave read things every so often about them opening up the PAF, but it never materializes. I wouldn't hold your breath. I was speaking to a rep from RM last week. The data will be released. I think they are still working on how to make it accessible. Well, if that is the case, awesome! But based on track record, I'll believe it when I see it. Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/#findComment-1067611 Share on other sites More sharing options...
JonnoTheDev Posted June 4, 2010 Share Posted June 4, 2010 The IT team are probably on strike! Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/#findComment-1067668 Share on other sites More sharing options...
malkocoglu Posted January 16, 2015 Share Posted January 16, 2015 // First, we need to take their postcode and get the lat/lng pair: $postcode = $_REQUEST['postcode']; // Sanitize their postcode: $search_code = urlencode($postcode); $url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . $search_code . '&sensor=false'; $json = json_decode(file_get_contents($url)); $lat = $json->results[0]->geometry->location->lat; $lng = $json->results[0]->geometry->location->lng; // Now build the lookup: $address_url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' . $lat . ',' . $lng . '&sensor=false'; $address_json = json_decode(file_get_contents($address_url)); $address_data = $address_json->results[0]->address_components; $street = str_replace('Dr', 'Drive', $address_data[1]->long_name); $town = $address_data[2]->long_name; $county = $address_data[3]->long_name; $city = $address_data[4]->long_name; $country = $address_data[5]->long_name; $array = array('street' => $street, 'town' => $town, 'city' => $city, 'country' => $country); //echo json_encode($array); echo $array = implode(", ",$array); Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/#findComment-1503162 Share on other sites More sharing options...
NetKongen Posted January 18, 2015 Share Posted January 18, 2015 Wikidata has alot of stuff - maybe it has what you are looking for? Quote Link to comment https://forums.phpfreaks.com/topic/203803-uk-post-code-database/#findComment-1503306 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.