# Resolve Address

**GET** `/v1/autocomplete/addresses/{address}/gbr`

Returns the complete address for an autocomplete suggestion, identified by its address ID.

This is the step of the autocomplete flow that costs a lookup. Fetching suggestions is free.

The API returns resolved addresses, including addresses outside the UK, in a UK format (up to 3 address lines) using UK nomenclature such as postcode and county.

An ID that matches no address returns `404`.

## Example request

**URL**

```http
https://api.ideal-postcodes.co.uk/v1/autocomplete/addresses/paf_23747771/gbr?api_key=ak_test
```

**curl**

```bash
curl -G 'https://api.ideal-postcodes.co.uk/v1/autocomplete/addresses/paf_23747771/gbr' \
  -d 'api_key=ak_test'
```

**JavaScript**

```javascript
import { createIdpcClient } from '@ideal-postcodes/sdk';
import { createAutocomplete } from '@ideal-postcodes/sdk/autocomplete';

const client = createIdpcClient({ apiKey: 'ak_test' });

// Debounces keystrokes, drops superseded requests and caches suggestions
const autocomplete = createAutocomplete({ client });

const hits = await autocomplete.find({ query: '10 downing' });
if (hits?.length) {
  const address = await autocomplete.resolve({ hit: hits[0] });
}
```

**JavaScript (direct)**

```javascript
import { createIdpcClient, resolveAddress } from '@ideal-postcodes/sdk';

const client = createIdpcClient({ apiKey: 'ak_test' });

const { data } = await resolveAddress({
  client,
  path: { address: 'paf_23747771' },
});
```

**Python**

```python
# pip install ideal-postcodes
from ideal_postcodes import IdealPostcodes

with IdealPostcodes("ak_test") as client:
    result = client.resolve_address("paf_23747771")
```

**Ruby**

```ruby
require "net/http"
require "json"

uri = URI("https://api.ideal-postcodes.co.uk/v1/autocomplete/addresses/paf_23747771/gbr")
uri.query = URI.encode_www_form(api_key: "ak_test")
result = JSON.parse(Net::HTTP.get(uri))["result"]
```

**PHP**

```php
<?php
// composer require ideal-postcodes/sdk
use IdealPostcodes\IdealPostcodes;

$client = IdealPostcodes::client('ak_test');
$result = $client->resolveAddress('paf_23747771')->result;
```

## Example response

**200 OK**

```json
{
  "code": 2000,
  "message": "Success",
  "result": {
    "id": "paf_23747771",
    "dataset": "paf",
    "country_iso": "GBR",
    "country_iso_2": "GB",
    "country": "England",
    "language": "en",
    "postcode": "SW1A 2AA",
    "postcode_inward": "2AA",
    "postcode_outward": "SW1A",
    "post_town": "London",
    "dependant_locality": "",
    "double_dependant_locality": "",
    "thoroughfare": "Downing Street",
    "dependant_thoroughfare": "",
    "building_number": "10",
    "building_name": "",
    "sub_building_name": "",
    "po_box": "",
    "department_name": "",
    "organisation_name": "Prime Minister & First Lord Of The Treasury",
    "udprn": 23747771,
    "umprn": "",
    "uprn": "100023336956",
    "postcode_type": "S",
    "su_organisation_indicator": "",
    "delivery_point_suffix": "1A",
    "line_1": "Prime Minister & First Lord Of The Treasury",
    "line_2": "10 Downing Street",
    "line_3": "",
    "premise": "10",
    "longitude": -0.12767,
    "latitude": 51.503541,
    "eastings": 530047,
    "northings": 179951,
    "county": "London",
    "county_code": "",
    "traditional_county": "Greater London",
    "administrative_county": "",
    "postal_county": "London",
    "district": "Westminster",
    "ward": "St. James's",
    "native": {
      "dataset": "paf",
      "postcode": "SW1A 2AA",
      "post_town": "London",
      "dependant_locality": "",
      "double_dependant_locality": "",
      "thoroughfare": "Downing Street",
      "dependant_thoroughfare": "",
      "building_number": "10",
      "building_name": "",
      "sub_building_name": "",
      "po_box": "",
      "department_name": "",
      "organisation_name": "Prime Minister & First Lord Of The Treasury",
      "udprn": 23747771,
      "postcode_type": "S",
      "su_organisation_indicator": "",
      "delivery_point_suffix": "1A"
    }
  }
}
```

## Path parameters

* `address` string

  **ID of address suggestion**

  ID of address suggestion provided by the API to fully resolve.

  Example: `paf_23747771`

## Query parameters

* `api_key` string optional

  **API Key**

  Your unique identifier that allows access to our APIs.

  Begins `ak_`. Available from your dashboard.

  Example: `ak_test`

* `tags` string optional

  **Tags**

  A comma separated list of tags to query over.

  Useful if you want to specify the circumstances in which the request was made.

  If you specify multiple tags, the response comprises only requests that satisfy all of them. Searching `"foo,bar"` queries only requests tagged both `"foo"` and `"bar"`.

  Example: `foo,bar`

* `remove_organisation` string optional

  **Remove Organisation**

  Removes organisation and department names from the address lines (`line_1`, `line_2`, ...). Remaining lines move up. Useful when delivering to people rather than businesses.

  Set `remove_organisation=true` to enable.

  `organisation_name`, `department_name` and the `native` record are unchanged. If removing the organisation and department would leave no address lines (e.g. `Asda PLC, London, SW1A 1AA`), they are kept and the lines are returned unchanged. Building and farm names (e.g. `hofname`, `adressetilleggsnavn`, `bdg_name`) are not removed.

  Enum: "true"

## Response

Response is framed in the standard `{ result, code, message }` envelope where `result` is a single `Address` record.

* `result` Address

  The standard Ideal Postcodes address, which maps both UK and International addresses.

  Its fields follow the layout UK address databases typically use, and much of it reflects Royal Mail's Postcode Address File, the UK's primary address database.

  The API converts non-UK addresses into the same UK layout so international addresses will also seamlessly insert into a standard address database. Fidelity to the local details is retained with the `native` address field.

  Pay attention to the address lines (`line_1`, `line_2` and `line_3`), post town, postcode, county and country. Together they are all you need to identify an address uniquely, in the UK or as an international address.

  For international addresses, cities map to `post_town` and states map to `county`.

  Every address carries a `native` object: the raw record from its source dataset, exactly as the dataset supplies it, with local detail the standard fields cannot hold. E.g.

  * ECAD records say whether an address sits in a Gaeltacht (Irish-speaking) district and whether the building is residential or commercial
  * USPS records carry the carrier route and congressional district
  * Kadaster records carry the floor area, year of completion and use (residential, office, retail)

  The postcode and address list endpoints return the older `AddressListItem` shape instead, where `native` is absent for the Royal Mail PAF family.

  * `id` string

    Globally unique internally generated identifier for an address

  * `dataset` string

    Indicates the provenance of an address.

    Values: "paf", "pafw", "pafa", "mr", "nyb", "usps", "ecaf", "ecad", "ab", "abp", "herewe", "heret", "heresa", "hereo", "herena", "heremeas", "heremea", "herem", "herei", "herehk", "hereee", "hereap", "gnaf", "kadaster", "kartverket", "sdfi", "cannar", "fodbosa", "mois", "upujp", "bev", "ban", "swt"

  * `country_iso` string

    3 letter country code (ISO 3166-1)

    Values: 243 possible values

  * `country_iso_2` string

    2 letter country code (ISO 3166-1)

    Values: 243 possible values

  * `country` string

    Full country names (ISO 3166)

    Values: 248 possible values

  * `language` string

    Language represented by 2 letter ISO Code (639-1)

    Values: 64 possible values

  * `line_1` string

    First address line. Often contains premise and thoroughfare information. For a commercial premise the first line is the full name of the registered organisation. Never empty.

  * `line_2` string

    Second address line. Often contains thoroughfare and locality information. May be empty.

  * `line_3` string

    Third address line. Takes the address elements left after `line_1` and `line_2` are filled; where the address needs more than three lines the remaining elements are joined into `line_3`, comma separated. May be empty.

  * `post_town` string

    The town or city used to route mail to the address. For UK addresses this is the Royal Mail post town, which is a routing instruction rather than the nearest town geographically. Present on every address.

  * `postcode` string

    Correctly formatted postcode. Capitalised and spaced. Empty (`""`) where the address has no postcode.

  * `county` string

    Whatever county data is available for the address. Normally the postal county. If that is not present it falls back to the administrative county, then to the traditional county. May be empty where none of the three is present.

  * `county_code` string

    Short code representing the county or province. May be empty (`""`)

  * `uprn` string

    UPRN stands for Unique Property Reference Number and is maintained by the Ordnance Survey (OS). Local governments in the UK have allocated a unique number for each land or property.

    Up to 12 digits in length.

    Multiple Residence premises currently share the same UPRN as the parent premise.

    May not be available for a small number of Great Britain addresses due to longer update cycles for Ordnance Survey's AddressBase datasets. Returns empty string "" in these instances, as it does for addresses outside the UK.

    Although UPRN takes an integer format, we encode and transmit this data as strings. As a 12 digit number, the UPRN can exceed the maximum safe integer `Number.MAX_SAFE_INTEGER` in most browsers causing this datapoint to be corrupted.

    Take special care when storing UPRN. As a 12 digit identifier, you will need 64 bits to encode every possible UPRN value. This means applications like Excel will corrupt cells containing UPRN values.

  * `udprn` one of

    UDPRN stands for 'Unique Delivery Point Reference Number'. Royal Mail assigns a unique UDPRN code for each premise on PAF. Simple, unique reference number for each Delivery Point. Unlikely to be reused when an address expires.

    Up to 8-digit numeric code. A new UDPRN is automatically assigned to each new Delivery Point added to PAF.

    Returns `0` on a UK dataset that carries no UDPRN for the address, and an empty string `""` on a non-UK address. Use `id` for an identifier present on every address.

    * integer
    * string

  * `umprn` one of

    A small minority of individual premises (as identified by a UDPRN) may have multiple occupants behind the same letterbox. These are known as Multiple Residence occupants and can be queried via the Multiple Residence dataset. Simple, unique reference number for each Multiple Residence occupant.

    Note: this will be an empty string `""` when not used.

    * string
    * number

  * `postcode_outward` string

    The first part of a postcode is known as the outward code. e.g. The outward code of BR8 7RE is BR8. Enables mail to be sorted to the correct local area for delivery. This part of the code contains the area and the district to which the mail is to be delivered, e.g. 'PO1', 'SW1A' or 'B23'.

    Empty (`""`) where the address has no UK postcode.

  * `postcode_inward` string

    The second part of a postcode is known as the inward code. e.g. The inward code of BR8 7RE is 7RE.

    The number identifies the sector in the postal district. The number is followed by 2 letters. The letters then define one or more properties in that sector.

    Empty (`""`) where the address has no UK postcode.

  * `dependant_locality` string

    A locality that qualifies the thoroughfare. Used where the same thoroughfare name occurs more than once in a post town and no dependant thoroughfare distinguishes them. May be empty.

  * `double_dependant_locality` string

    Supplements dependant locality. Supplied where the dependant locality itself occurs twice in the same locality. May be empty.

  * `thoroughfare` string

    Also known as the street or road name. May be empty.

  * `dependant_thoroughfare` string

    Supplements thoroughfare. Used where a thoroughfare name occurs twice in the same post town, to identify the address uniquely. May be empty.

  * `building_number` string

    Number identifying the premise on a thoroughfare or dependant thoroughfare. May be empty.

  * `building_name` string

    Name of a residential or commercial premise. May be empty.

    Examples:

    * The Manor
    * 1-2
    * A
    * 12A
    * K
    * Victoria House

  * `sub_building_name` string

    Identifies a unit where a premise is split into flats, apartments or business units. Cannot be present without either building\_name or building\_number. E.g. Flat 1, A, 10B. May be empty.

  * `po_box` string

    PO Box number for the address, occasionally a combination of numbers and letters. Allocated to Large User postcodes only. May be empty.

  * `department_name` string

    Supplements organisation name to identify a department within the organisation. May be empty.

  * `organisation_name` string

    Name of the business or organisation at this address. May be empty.

  * `postcode_type` string

    Royal Mail postcode user type. UK addresses only.

    * `S` small user. The postcode identifies a group of delivery points. There are on average 19 delivery points per postcode, and never more than 100
    * `L` large user. The postcode is assigned to a single address, either because of the volume of mail it receives or because a PO Box or Selectapost service is set up

    Empty (`""`) where not applicable.

    Values: "S", "L", ""

  * `su_organisation_indicator` string

    `Y` where an organisation is present at a small user postcode. Empty (`""`) otherwise. UK addresses only.

  * `delivery_point_suffix` string

    Two-character code (the first numeric, the second alphabetical) which, added to the postcode, uniquely identifies a delivery point. May be reused once a delivery point is deleted, though not until every remaining code in the range has been allocated. Always `1A` for a large user postcode, since each large user has its own postcode. Empty (`""`) where not available.

  * `premise` string

    A pre-computed string which sensibly combines building\_number, building\_name and sub\_building\_name. Those three fields hold raw dataset values and can be difficult to parse if you are unaware of how they work together, so we also provide this single, simple premise string. Ideal if you want to pull premise information and thoroughfare information separately instead of using our address lines data.

  * `administrative_county` string

    The current administrative county to which the postcode has been assigned.

    A Unitary Authority name, where one is present. If there is no Unitary Authority, the County name is used. This information is not static, because County boundaries may change due to administrative changes.

    Source: ONS. May be empty.

  * `postal_county` string

    Postal counties were used for the distribution of mail before the Postcode system was introduced in the 1970s. The Former Postal County was the Administrative County at the time. This data rarely changes. May be empty.

  * `traditional_county` string

    Traditional counties are provided by the Association of British Counties. It is historical data, and can date from the 1800s. May be empty.

  * `district` string

    The current district/unitary authority to which the postcode has been assigned. May be empty.

  * `ward` string

    The current administrative/electoral area to which the postcode has been assigned. May be empty for a small number of addresses.

  * `longitude` Longitude

    The longitude of the address or postcode (WGS84).

    Can be a positive or negative decimal. E.g. -0.1283983

    Returns an empty string if no location data is available.

    * string
    * number

  * `latitude` Latitude

    The latitude of the address or postcode (WGS84).

    Can be a positive or negative decimal. E.g. `51.5083983`.

    Returns an empty string if no location data is available.

    * string
    * number

  * `eastings` Eastings

    Eastings reference using the [Ordnance Survey National Grid reference system](https://en.wikipedia.org/wiki/Ordnance_Survey_National_Grid).

    Northern Ireland Eastings uses the [Irish Grid Reference System](https://en.wikipedia.org/wiki/Irish_grid_reference_system).

    Metres from origin. E.g. `550458`

    Returns an empty string if no location data is available. Otherwise a number is returned.

    * string
    * number

  * `northings` Northings

    Northings reference using the [Ordnance Survey National Grid reference system](https://en.wikipedia.org/wiki/Ordnance_Survey_National_Grid).

    Northern Ireland Northings uses the [Irish Grid Reference System](https://en.wikipedia.org/wiki/Irish_grid_reference_system).

    Metres from origin. E.g. `180458`

    Returns an empty string if no location data is available. Otherwise a number is returned.

    * string
    * number

  * `native` NativeRecord

    The raw dataset record backing an address, exactly as the dataset supplies it. One schema per dataset; `dataset` on the record says which.

    * Royal Mail Postcode Address File Address [Full guide](/docs/data/paf.md)
    * Multiple Residence Address [Full guide](/docs/data/mr.md)
    * Not Yet Built Address [Full guide](/docs/data/nyb.md)
    * PAF Alias Address [Full guide](/docs/data/paf-aliases.md)
    * Welsh PAF Address [Full guide](/docs/data/welsh-paf.md)
    * AddressBase Core Address [Full guide](/docs/data/addressbase-core.md)
    * AddressBase Premium Address [Full guide](/docs/data/addressbase-premium.md)
    * USPS Address [Full guide](/docs/data/usps.md)
    * Ireland ECAD Address [Full guide](/docs/data/ecad.md)
    * Ireland ECAF Address [Full guide](/docs/data/ecaf.md)
    * HERE Address [Full guide](/docs/data/here.md)
    * Australia G-NAF Address [Full guide](/docs/data/gnaf.md)
    * Netherlands Kadaster Address [Full guide](/docs/data/kadaster.md)
    * Norway Kartverket Address [Full guide](/docs/data/kartverket.md)
    * Denmark SDFI Address [Full guide](/docs/data/sdfi.md)
    * Canada NAR Address [Full guide](/docs/data/cannar.md)
    * Belgium FOD BOSA Address [Full guide](/docs/data/fodbosa.md)
    * South Korea MOIS Address [Full guide](/docs/data/mois.md)
    * Japan UPU Address [Full guide](/docs/data/upujp.md)
    * Austria BEV Address [Full guide](/docs/data/bev.md)
    * France BAN Address [Full guide](/docs/data/ban.md)
    * Switzerland and Liechtenstein Address [Full guide](/docs/data/swt.md)
