Developers

This service is designed to be easy to use and incorporate in to your existing systems.

You can complete a postcode distance search from the homepage or using the HTTP Request method below.

HTTP Request

Using HTTP GET you can send the following data to the URL http://ukpostcodes.tenfourzero.net/http_distance.html:

FieldDescriptionExample(s)
usernameYour MD5 encoded username.14c4b06b824ec593239362517f538b29
passwordYour MD5 encoded password.5f4dcc3b5aa765d61d8327deb882cf99
fromThe first postcode."SW1A 2AA" or "sw1a2aa"
toThe second postcode."SW1A 0AA" or "sw1a0aa"
unitUnit of measurement required."km" or "miles"

For example:

http://ukpostcodes.tenfourzero.net/http_distance.html?username=14c4b06b824ec593239362517f538b29&password=5f4dcc3b5aa765d61d8327deb882cf99&from=sw1a2aa&to=sw1a0aa&unit=km

Example PHP Code

An example of how to use the system in PHP:

<?php
$url="http://ukpostcodes.tenfourzero.net/http_distance.html";
$username="14c4b06b824ec593239362517f538b29";
$password="5f4dcc3b5aa765d61d8327deb882cf99";
$unit="km";
$from=ereg_replace("[^a-z0-9]","",strtolower($_POST["from"]));
$to=ereg_replace("[^a-z0-9]","",strtolower($_POST["to"]));
$xml=file_get_contents($url."?username=".$username."&password=".$password."&from=".$from."&to=".$to."&unit=".$unit);
?>

Return Data

An XML file is returned which contains the distance up to ten decimal places and an accuracy rating.

For testing purposes, you can use the URL http://ukpostcodes.tenfourzero.net/http_distance_exmaple.xml which returns the result 0.1234567890km accurate to within 1 metre.

For example:

<?xml version="1.0" encoding="utf-8"?>
<result>
  <distance>0.4624447824</distance>
  <unit>km</unit>
  <accuracy>Accurate within 10 metres.</accuracy>
</result>

Or:

<?xml version="1.0" encoding="utf-8"?>
<result>
  <error>Username and password do not match.</error>
</result>

Or:

<?xml version="1.0" encoding="utf-8"?>
<result>
  <error>Start postcode could not be validated.</error>
</result>

Or:

<?xml version="1.0" encoding="utf-8"?>
<result>
  <error>End postcode could not be validated.</error>
</result>