Get GB Postcode Data

Get GB Postcode Data API will return all the available data for the supplied UK postcode.

Please read API Overview first


API Endpoint

The Get GB Postcode Data API endpoint won't change. It can be set as a constant.

https://api.autoaddress.ie/2.0/getGBPostcodeData
	

N.B. This EndPoint URL resolves to a dynamic IP address, please be aware of this when making DNS and Firewall decisions.


Request

To get the data for a UK postcode, a simple  GET request from your desired language is all that is needed.

  • cURL
curl -v "https://api.autoaddress.ie/2.0/getgbpostcodedata?key=YOUR_KEY
&postcode=YOUR_UK_POSTCODE"
	
  • jQuery
$.ajax({
   type: "GET",
   dataType: "jsonp",
   url: "https://api.autoaddress.ie/2.0/getgbpostcodedata",
data : {
key: "YOUR_KEY",
postcode: "YOUR_UK_POSTCODE"
},
success: function(data){
//do something with data
}
});
	
  • Angular JS
$http.jsonp('https://api.autoaddress.ie/2.0/getgbpostcodedata',{
   params: {
      key: "YOUR_KEY",
      postcode: "YOUR_UK_POSTCODE"
   }
}).success(function(data){
   //do something with data
});
	
  • Ruby
require 'json'
require 'net/http'

uri = URI.parse("https://api.autoaddress.ie/2.0/getgbpostcodedata?key=YOUR_KEY&postcode=YOUR_UK_POSTCODE")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = http.get(uri.request_uri)
result = JSON.parse(response.body)
	
  • Python
import json
import urllib2
 
Response = urllib2.urlopen ("https://api.autoaddress.ie/2.0/getgbpostcodedata?key=YOUR_KEY&postcode=YOUR_UK_POSTCODE")
jsonResult = json.load(Response)
	
  • C#
using System.IO;
using System.Net;

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.autoaddress.ie/2.0/getgbpostcodedata?key=YOUR_KEY&postcode=YOUR_UK_POSTCODE");
request.Method = WebRequestMethods.Http.Get;
request.Accept = "application/json";

using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
   var result = new StreamReader(response.GetResponseStream()).ReadToEnd();
}
			

Response

The following is a sample JSON response returned for a Get GB Postcode Data API request.

{
  "result": {
    "code": 100,
    "text": "PostcodeValid"
  },
  "postcode": "BT1 2AA",
  "spatialInfo": {
    "wgs84": {
      "location": {
        "longitude": -5.92653,
        "latitude": 54.599535
      }
    }
  },
  "input": {
    "key": "YOUR_KEY",
    "txn": "c2b62e9d-0213-4462-963e-b2787816a27d",
    "postcode": "BT1 2AA"
  },
  "links": [
    {
      "rel": "self",
      "href": "http://api.autoaddress.ie/2.0/getgbpostcodedata?key=YOUR_KEY&postcode=BT1+2AA"
    }
  ]
}
	

Input Fields

Name Type Default Description
key* string None Licence key
IMPORTANT: The key parameter name must be all lower case.
postcode* string None UK postcode
txn string None Transaction ID from previous call in the session

* Required Field


Output Fields

Name Type Description
result enum Result of the search
  • Unknown,
  • PostcodeValid = 100,
  • PostcodeInvalid = 200
postcode string UK postcode
spatialInfo object This object contains spatial information which is outlined below
input object Input object with request input fields.
links link [ ] An array of Link objects (described below).
spatialInfo Object
Name Type Description
wgs84 object WGS 84 latitude and longitude
Link Object
Name Type Description
rel string API response usually includes an array of HATEOAS links. This allows interaction with the API solely through the hyperlinks we provide you. You no longer need to hardcode logic into your client in order to use our API.
href string The hyperlink the client should follow is stored in the value of “href” property. That value can have some internal parameters, so the client should not parse it or modify it in any way.