Postcode or Address Finder

Use our data to find a UK address from a postcode or vice versa

Our data is the most up-to-date source of address information you will find in the UK.

Having accurate up-to-date address and postcode data is vital for all CRM systems, and any websites and apps that require customers to create an account using their name and address.

You can use our data to facilitate a postcode lookup, for customers to then choose their address from a list, or add a postcode to a partial UK address. This makes it easier for customers to complete signup or enquiry forms and ensures the data you receive is accurate, up-to-date and complete.

As a data cleansing tool our service can be used to ensure full and accurate data within CRM systems for marketing campaigns. Old addresses can be updated and incomplete addresses improved, that may be missing postcodes for example.

API method to use: address_search

How it works

We can identify a full and accurate address from a partial address and/or postcode. All you need to do is submit the information you have and or API method will complete and update.

The method returns a list of UK addresses and postcodes that match your search criteria, when the following data is supplied:

  • a partial address (when conducting a postcode search)
  • a postcode, plus optional Building name/number (when conducting an address search)

More details on mandatory and optional parameters, plus a list of returned values can be found in the Documentation section.

Address finder demo

A demo of the address_search method can be found in the Demo section. Alternatively, you can see the T2A address finder in action on ukphonebook.com.

API method to use: address_search
|
Credits per use: 1.7

Searches the UK postcodes data (PAF) to find a UK address from a postcode or vice versa.

This is the most up-to-date source of address information you can find in the UK.

We can identify a full and accurate address from a partial address and/or postcode - all you need to do is enter the information you have and we will complete and update it. We know how important it is to have accurate contact information for your customers so we want to make it as easy as possible for you to have a complete and accurate customer contact database.

Save valuable time and effort by adding this service to your CRM system, website or other business application. It can be used as a data cleansing tool or can facilitate the process of filling in address details on forms to ensure that the information provided is accurate.

Mandatory Parameters


Name Description
api_key or javascript_key Use your API key if invoking server-side. If invoking from the browser via JavaScript, generate a JavaScript key using the javascript_key method.

Optional Parameters


Name Description
client You can optionally include an identifier for your final client or user. This is logged in your usage log and you will be able to view your usage statistics by client.
output Set to json for a JSON response; the default response is XML. Not applicable to the SOAP API.
callback When using JSON, specify a JSONP wrapper in which the JSON response is to be wrapped.
postcode Enter a UK postcode; you may also enter a house number as the address parameter.
address If used with a postcode, this is an optional house number; if used alone, this is the address to be searched for.
records_per_page Specify the number of records to return on the current page. We offer page caching for this method - once your search is invoked, we store the pages on our server for 60 minutes; a subsequent request for a page of results from that search is displayed from the cache, at no charge to you. See result page caching.
page_num Zero based integer - current page number to return.

Returned Values


The XML response is contained within a <address_search_res> element.

Name Description
status Returns ok if the operation has succeeded, or error if an error has occurred; Returns the error_code for error details.
error_code Returns the error code when the status is error. See below for error codes.
t2a_version_number The current API version number.
credit_used The number of credits used in order to execute the request.
mode Returns normal or test when executed in the free test mode.
address_list An array of address records.
total_records

The total number of records, irrespective of the number displayed on any page.

This is only used when a address_list is present.

page_number

Current page being displayed, a zero-based integer.

This is only used when a address_list is present.

records_per_page

The number of records returned on the current page.

Defaults to 100. Set to a factor of 100, such as 10,20 or 25 to return the <person> records in smaller chunks.

Each block of 100 records is chargeable, so, for example, if your search returns 150 records, and your records_per_page is 25, pages 0-3 (parameter page_num, is zero-based) are already paid for, but if the 5th page of results is viewed, a credit value is debited.

The values in the <address> element.

Name

Type

Description

address_id

string

The unique ID of this address

line_1

string

Address line 1

line_2

string

Address line 2

line_3

string

Address line 3

place

string

The place. If the address is in a named area within a large town, this will be that area, otherwise it will be the town. place is never empty if town is set.

town

string

The town; only used if the address is in a named area within that town.

postcode

string

The UK postal code, formatted to include the space.

addr_single_line

string

The address, formatted as a single line. Commas are inserted between the major elements, and the postcode is included, if available.

building

string

The building component in the PAF record.

This is used to create line_1,line_2 and line_3

street

string

The street component in the PAF record.

This is used to create line_1,line_2 and line_3

street2

string

The sub-street component in the PAF record.

This is used to create line_1,line_2 and line_3

premises

string

The premises component in the PAF record.

This is used to create line_1,line_2 and line_3

organisation

string

The organisation name component in the PAF record.

This is used to create line_1,line_2 and line_3

Error Codes


Name

Description

missing_address

The address parameter is missing. Required where place is not specified.

See the common error codes.

Free Test Mode


When operating in the free test mode errors are returned if mandatory parameters are missing, or it returns a dummy data response, in an identical format to a real response.

Note that the mode is returned as test when the method is operating in the free test mode.

Example XML Response


<address_search_res>
  <mode>test</mode>
  <status>ok</status>
  <credit_used>0</credit_used>
  <t2a_version_number>3.3.8.0</t2a_version_number>
  <address_list>
    <address>
      <address_id>
        8ik_G8DqPx65nlEznu6Ld76mI-BCSeeM0VUz5RInRhtY14yegBGYH3bmKdH5gTF-dyANGIbqGuO9cV05-gCWIlzn
      </address_id>
      <line_1>56</line_1>
      <line_2>Sails Drive</line_2>
      <line_3/>
      <place/>
      <town>York</town>
      <postcode>Y10 3LR</postcode>
      <addr_single_line>56 Sails Drive, York, Y10 3LR</addr_single_line>
      <building/>
      <street>Sails Drive</street>
      <street2/>
      <premises>56</premises>
      <organisation/>
    </address>
  </address_list>
</address_search_res>

Example JSON Response


{
  "address_list":[
  {
    "line_1":"4 Imagination Gardens",
    "line_2":"Magic Street",
    "line_3":"",
    "place":"Heslingdown",
    "town":"York",
    "postcode":"YO10 5NP"
  }
  ],
  "t2a_version_number":"1.0.0",
  "status":"ok"
}


Method Limits


This method returns a maximum of 1,000 addresses; please note that each block of 100 records is chargeable (see below)

Result Caching


When a chargeable result is found (a list of persons) , the list is cached on our server for 60 minutes. If the successful search is repeated during that time, the list is displayed, but there is no charge.

Charging Policy


The method only charges when a valid name and/or address has been supplied.

A credit charge is then levied for every new consecutive block of 100 records viewed.

The following events are not chargeable for this method

  • Invalid place
  • Invalid input

There are two ways to authenticate your application with the T2A API. The two implementation examples on this page cover each type of authentication

We recommend using an API key for internal applications and the javascript key for public facing applications where you would want to protect your API key.

Please note: The examples below run on a sandbox environment which return sample data. To quality check the data we provide, up to 3 free searches are available in the demo tab with results showing live [REDACTED] data.

API key


<div class="address-search-example">
  <form class="address-search-form">

    <div class="form-group">
          <label for="surname">Address</label>
          <input type="text" class="form-control" id="address" placeholder="Building name or number">
      </div>

    <div class="form-group">
          <label for="surname">Postcode</label>
          <input type="text" class="form-control" id="postcode" placeholder="Postcode">
      </div>

    <button type="submit" class="btn example-submit">Submit</button>
  </form>
</div>

<div class="results">
  <div id="results-output"></div>
  <a class="results-return" href="#">Back to search</a>
</div>
                
.address-search-example, .results {
  margin: 20px auto;
  width: 400px;
}

form.address-search-form, .results {
    background-color: #F6F6F6;
    border: 1px solid #CBCBCB;
    padding: 15px;
}

.example-submit {
    background-color: #F0614C;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 400;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.193em;
    width: 138px;
    height: 41px;
    margin-top: 10px;
}

.results {
  display: none;
}

.results-return {
    font-weight: 600;
    color: #F0614C;
}

#results-output span {
    font-weight: bold;
    text-transform: capitalize;
}

#results-output hr {
    border-top: 1px solid #000;
}

.error {
  font-size: 11px;
  color: #f00;
}
                
$(document).ready(function(){ 	
    $(".address-search-form").submit(function(e) {
        e.preventDefault();	

        $('.error', $(this)).remove();

        var address = $("#address");        var postcode = $("#postcode");        if($('.error', $(this)).length) {	
            $('.error', $(this)).first().next('input').focus();
        } else {
    
            $.ajax({
                url: 'https://api.t2a.io/rest/rest.aspx',
                dataType: 'json',
                data: {
                    'method'   : "address_search",
                    'api_key'  : 'sandbox',
                    'address' : address.val(),
                    'postcode' : postcode.val(),
                    'output'   : 'json'
                    },
                success: function(result){
                    if(result.status == "error") {
                        $('#results-output').append('<p class="output"><strong>Error:</strong>' + result.error_code +'</p>');
                    } else {
                        var i = 0;
                        if(typeof result.address_list !== "undefined") {
                            result.address_list.forEach(function(address_list_item){
                                if(i>0){
                                    $('#results-output').append('<hr>');
                                }
                                var exceptionsArray = ['META', 'created_details', 'years_list', 'address_key', 'organisation_key', 'dob_details'];
                                    
                                for (var key in address_list_item) {
                                    if(!key.includes('id') && !exceptionsArray.includes(key) ) {
                                        var keyName = key.replace('_', ' ');
                                        $('#results-output').append('<p class="output"><span>' + keyName + ':</span> ' + address_list_item[key] + '</p>');
                                    }
                                }
                                i++;
                            });
                        }
                    }
                    $('.address-search-example').hide();
                    $('.results').show(); 
               }
            });
        }
    });
    
    $('.results-return').on('click', function(e){
        e.preventDefault();
        $('#results-output').empty();
        
        $('.address-search-example').show();
        $('.results').hide();
    });
});

function errorBefore(msg, insertBefore) {
    $('<p class="error">' + msg + '</p>').insertBefore(insertBefore);
}

Javascript key


<div class="address-search-example">
  <form class="address-search-form">

    <div class="form-group">
          <label for="surname">Address</label>
          <input type="text" class="form-control" id="address" placeholder="Building name or number">
      </div>

    <div class="form-group">
          <label for="surname">Postcode</label>
          <input type="text" class="form-control" id="postcode" placeholder="Postcode">
      </div>

    <button type="submit" class="btn example-submit">Submit</button>
  </form>
</div>

<div class="results">
  <div id="results-output"></div>
  <a class="results-return" href="#">Back to search</a>
</div>
                
.address-search-example, .results {
  margin: 20px auto;
  width: 400px;
}

form.address-search-form, .results {
    background-color: #F6F6F6;
    border: 1px solid #CBCBCB;
    padding: 15px;
}

.example-submit {
    background-color: #F0614C;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 400;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.193em;
    width: 138px;
    height: 41px;
    margin-top: 10px;
}

.results {
  display: none;
}

.results-return {
    font-weight: 600;
    color: #F0614C;
}

#results-output span {
    font-weight: bold;
    text-transform: capitalize;
}

#results-output hr {
    border-top: 1px solid #000;
}

.error {
  font-size: 11px;
  color: #f00;
}
                
$(document).ready(function(){ 	
    $(".address-search-form").submit(function(e) {
        e.preventDefault();	

        $('.error', $(this)).remove();

        var address = $("#address");        var postcode = $("#postcode");        if($('.error', $(this)).length) {	
            $('.error', $(this)).first().next('input').focus();
        } else {
            $.ajax({
                url: 'https://t2a.io/ajax/getExampleJSKey',
                dataType: 'json',
                success: function (result) {       
                        
                    if (result.status)
                    {       
                        $.ajax({
                            url: 'https://api.t2a.io/rest/rest.aspx',
                            dataType: 'json',
                            data: {
                                'method'   : "address_search",
                                'javascript_key'  : result.javascript_key,
                                'domain' : "t2a.io", 
                                'address' : address.val(),
                                'postcode' : postcode.val(),
                                'output'   : 'json'
                            },
                            success: function(result){
                        if(result.status == "error") {
                            $('#results-output').append('<p class="output"><strong>Error:</strong>' + result.error_code +'</p>');
                        } else {
                            var i = 0;
                            if(typeof result.address_list !== "undefined") {
                                result.address_list.forEach(function(address_list_item){
                                    if(i>0){
                                        $('#results-output').append('<hr>');
                                    }
                                    
                                    var exceptionsArray = ['META', 'created_details', 'years_list', 'address_key', 'organisation_key', 'dob_details'];
                                    
                                    for (var key in address_list_item) {
                                        if(!key.includes('id') && !exceptionsArray.includes(key) ) {
                                            var keyName = key.replace('_', ' ');
                                            $('#results-output').append('<p class="output"><span>' + keyName + ':</span> ' + address_list_item[key] + '</p>');
                                        }
                                    }
                                    i++;
                                });
                            }
                       }
                                $('.address-search-example').hide();
                                $('.results').show(); 
                            }
                        });
                    }
                }
            });
        }
    });
    
    $('.results-return').on('click', function(e){
        e.preventDefault();
        $('#results-output').empty();
        
        $('.address-search-example').show();
        $('.results').hide();
    });
});

function errorBefore(msg, insertBefore) {
    $('<p class="error">' + msg + '</p>').insertBefore(insertBefore);
}

This example first needs to call to a file on your server, which will provide the user with an API key from your javascript key.

In our example above we have used a PHP file located at ajax/getExampleJSKey which looks like the example below

    <?php

        $url = 'https://api.t2a.io/rest/rest.aspx'
            . "?method=javascript_key"
            . "&api_key=sandbox" .
            . "&domain=" . $_SERVER['HTTP_HOST'];
            . '&ip_address=' . get_user_ip()
            . "&lifetime_minutes=10";

        $result = simplexml_load_file($url);

        if ($result->javascript_key) {
            echo (string)$result->javascript_key;
        }

API Endpoint & Authentication

Demo

Price calculator

Price Calculator

Number of checks: 50 Price per check: 50p