Postcode APIs

There are a few web services used internally by this website which I've decided to document and make publicly available. I can't provide any quality of service guarantees and may withdraw or limit usage if I find my server performance is being affected. Parameters should be passed as query strings to the APIs.

Create random postcodes

Creates a list of random UK postcodes with their latitude and longitude

URL
https://www.doogal.co.uk/CreateRandomPostcode.ashx

Parameter Usage Description Default
output Optional Whether to output as xml or csv csv
count Optional Number of random postcodes to create (maximum 1000) 1
startWith Optional Postcode area to restrict results to 1

Get nearby postcodes

Gets UK postcodes close to the specified latitude/longitude

URL
https://www.doogal.co.uk/GetPostcodesNear.ashx

Parameter Usage Description Default
lat Required if postcode not specified The latitude of the location to find postcodes near
lng Required if postcode not specified The longitude of the location to find postcodes near
postcode Required if lat and lng not specified A postcode to find postcodes near
distance Optional Maximum distance (in KMs) from the location to return results for. Maximum value supported is 16.09344 KMs (10 miles) Returns at least 10 results
output Optional Whether to output as xml, json or csv xml
searchType Optional Whether to output sectors, districts or individual postcodes.
Possible values are postcodes, sectors, districts
postcodes

Get postcode details

Gets the latitude, longitude, quality, administrative areas, altitude (in metres), rural/urban classification and Travel to work area of a UK postcode, returned as tab-separated text. This can also be used with partial postcodes but only latitude and longitude will be returned.
Administrative areas returned are Constituency, District, Ward, Lower Super Output Area, County, Region, Country, National park

URL
https://www.doogal.co.uk/GetPostcode.ashx

Parameter Usage Description
postcode Required The postcode to get details for
PHP example
$contents = file_get_contents("https://www.doogal.co.uk/GetPostcode.ashx?postcode=KT5%208AN");
$splitContents = explode("\t", $contents);
print("Postcode - " . $splitContents[0] . "<br/>");
print("latitude - " . $splitContents[1] . "<br/>");
print("longitude - " . $splitContents[2] . "<br/>");
print("quality - " . $splitContents[3] . "<br/>");
print("Constituency - " . $splitContents[4] . "<br/>");
print("District - " . $splitContents[5] . "<br/>");
print("Ward - " . $splitContents[6] . "<br/>");
print("Lower Super Output Area - " . $splitContents[7] . "<br/>");
print("County - " . $splitContents[8] . "<br/>");
print("Region - " . $splitContents[9] . "<br/>");
print("Country - " . $splitContents[10] . "<br/>");
print("National park - " . $splitContents[11] . "<br/>");
print("Altitude - " . $splitContents[12] . "<br/>");
print("Rural/urban - " . $splitContents[13] . "<br/>");
print("Travel to work area - " . $splitContents[14] . "<br/>");
		

Create random phone number

Creates a random phone number for the specified latitude and longitude. The phone number may not be in the correct phone code area, but it will definitely be in a nearby area

URL
https://www.doogal.co.uk/CreateRandomPhoneNumber.ashx

Parameter Usage Description
lat Required The latitude of the location to generate a phone number for
lng Required The longitude of the location to generate a phone number for

Get postcodes KML

Get the KML for individual postcodes for postcode areas, districts, sectors or individual postcodes

URL
https://www.doogal.co.uk/MultiplePostcodesKML.ashx

Parameter Usage Description
postcodes Required A comma separated list of postcode areas, districts, sectors or individual postcodes to retrieve the KML for
active Optional If true, only active postcodes will be returned

Get postcodes polygon KML

Get the polygon KML for postcode areas, districts or sectors

URL
https://www.doogal.co.uk/GetAreaKml.ashx

Parameter Usage Description
postcodes Required A comma separated list of postcode areas, districts or sectors to retrieve the KML polygons for
topLevel Optional If true, only returns the polygon of the requested area. Otherwise returns the requested level and the next lower level

Get nearest UK station

Gets the closest UK station to the specified latitude/longitude

URL
https://www.doogal.co.uk/GetNearestStation.ashx

Parameter Usage Description
lat Required The latitude of the location
lng Required The longitude of the location