AddressLookupService

<back to all web services

PostcodeLookupRequest

Postcode Lookup Requests

This RESTful API returns UK Address data in both POST and GET. Input=Postcode(Mandatory), HouseNameorNumber=(Optional). You must provide valid authentication to make a request.

Requires Authentication
The following routes are available for this service:
POST/addressCall to list addressesPOST request to search for addresses. Using Postcode and House Name/Number as input.
GET/address/{Postcode}Call to list addressesGET request to search for addresses. Using Token, Postcode and House Name/Number as input.
GET/address/{Postcode}/{HouseNo}Call to show a specific addressGET request to search for addresses. Using Token, Postcode and House Name/Number as input.
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


/** @description This RESTful API returns UK Address data in both POST and GET. Input=Postcode(Mandatory), HouseNameorNumber=(Optional). You must provide valid authentication to make a request. */
// @Api(Description="This RESTful API returns UK Address data in both POST and GET. Input=Postcode(Mandatory), HouseNameorNumber=(Optional). You must provide valid authentication to make a request.")
// @ApiResponse(Description="Bad Request: Try formatting the request differently. See the /swagger-ui/ documentation for more details", StatusCode=400)
// @ApiResponse(Description="Something went wrong here. Please contact your administrator or servicedesk@uk.rapp.com for more details.", StatusCode=500)
// @ApiResponse(Description="Request Accepted", StatusCode=202)
// @ApiResponse(Description="No content returned", StatusCode=204)
class PostcodeLookupRequest implements JsonSerializable
{
    public function __construct(
        /** @description Using a Postcode to return addresses. */
        // @ApiMember(DataType="string", Description="Using a Postcode to return addresses.", IsRequired=true, Name="Postcode")
        /** @var string */
        public string $Postcode='',

        /** @description Optional input value to limit the return data to a specific address. */
        // @ApiMember(DataType="string", Description="Optional input value to limit the return data to a specific address.", Name="House Name or Number")
        /** @var string|null */
        public ?string $HouseNo=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Postcode'])) $this->Postcode = $o['Postcode'];
        if (isset($o['HouseNo'])) $this->HouseNo = $o['HouseNo'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Postcode)) $o['Postcode'] = $this->Postcode;
        if (isset($this->HouseNo)) $o['HouseNo'] = $this->HouseNo;
        return empty($o) ? new class(){} : $o;
    }
}

PHP PostcodeLookupRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /address HTTP/1.1 
Host: webservices.mbukdatabase.co.uk 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	Postcode: String,
	HouseNo: String
}