# Lookup Postcode

**GET** `/v1/postcodes/{postcode}`

Returns the complete list of addresses for a postcode. Postcode searches are space and case insensitive.

Each request looks up one postcode. To extract the addresses for several postcodes, send one request per postcode.

Use it to power postcode driven address searches, like [Postcode Lookup](https://docs.ideal-postcodes.co.uk/docs/postcode-lookup).

Postcode lookup covers the United Kingdom, the Republic of Ireland, the Netherlands and Singapore. The API detects the format of the postcode you submit. UK and Irish postcodes are searched by default. For a Dutch or Singapore postcode, set `context` to `NLD` or `SGP`, or to `GLOBAL` to accept any supported format.

UK postcodes need PAF, Multiple Residence, Not Yet Built, PAF Alias, PAF Welsh, AddressBase or AddressBase Premium on your key. Eircodes need ECAD or ECAF. Dutch postcodes need Kadaster. Singapore postcodes need HERE Asia Pacific. Without a matching licence the request is rejected.

An unfound postcode costs no lookup. A postcode that returns addresses costs one.

## Postcode Not Found

Invalid postcodes do not affect your lookup balance. The API returns a `404` response with this body:

```json
{
  "code": 4040,
  "message": "Postcode not found",
  "suggestions": ["SW1A 0AA"]
}
```

### Suggestions

If a postcode cannot be found, the API returns up to 5 of the closest matching postcodes. It corrects common errors first (e.g. mixing up `O` and `0` or `I` and `1`).

If the suggestion list is small (fewer than 3), the correct postcode is likely to be among them. Notify the user or trigger new searches immediately.

The suggestion list is empty if the postcode has deviated too far from a valid postcode format.

## Multiple Residence

A small number of postcodes return more than 100 premises. The API returns 100 addresses per page, so use `page` to paginate the result set.

## Example request

**URL**

```http
https://api.ideal-postcodes.co.uk/v1/postcodes/SW1A2AA?api_key=ak_test
```

**curl**

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

**JavaScript**

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

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

const { data } = await postcodes({
  client,
  path: { postcode: 'SW1A2AA' },
});
```

**Python**

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

with IdealPostcodes("ak_test") as client:
    result = client.postcodes("SW1A2AA")
```

**Ruby**

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

uri = URI("https://api.ideal-postcodes.co.uk/v1/postcodes/SW1A2AA")
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->postcodes('SW1A2AA')->result;
```

## Example response

**200 OK**

```json
{
  "result": [
    {
      "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,
      "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,
      "country": "England",
      "traditional_county": "Greater London",
      "administrative_county": "",
      "postal_county": "London",
      "county": "London",
      "district": "Westminster",
      "ward": "St. James's",
      "uprn": "100023336956",
      "id": "paf_23747771",
      "country_iso": "GBR",
      "country_iso_2": "GB",
      "county_code": "",
      "language": "en",
      "umprn": "",
      "dataset": "paf"
    }
  ],
  "code": 2000,
  "message": "Success",
  "limit": 100,
  "page": 0,
  "total": 1
}
```

**404 Not Found**

response.jsonjson

```json
{
  "code": 4040,
  "message": "Postcode not found",
  "suggestions": ["SW1A 0AA"]
}
```

## Path parameters

* `postcode` string

  Postcode to retrieve

  Example: `SW1A 2AA`

## 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`

* `filter` string optional

  **Restrict Result Fields**

  Comma separated whitelist of address elements to return.

  E.g. `filter=line_1,line_2,line_3` returns only the `line_1`, `line_2` and `line_3` address elements in your response.

  Example: `line_1,line_2,line_3`

* `page` integer optional

  **Page**

  0 indexed indicator of the page of results to receive. Virtually all postcode results are returned on page 0.

  A small number of Multiple Residence postcodes may need pagination (i.e. have more than 100 premises).

  Format: `int32`

  Default: `0`

  Example: `1`

* `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"

* `dataset` array optional

  **Filter by Dataset**

  Comma-separated list of datasets to search within.

  Filters results to only include addresses from the specified datasets. Useful for keys with multiple overlapping datasets enabled (e.g. `paf` and `abp`).

  Example: `paf,nyb`

* `context` string optional

  **Context**

  Limits search results, typically within a country.

  Example: `GBR`

## Response

`result` is an array of flat `AddressListItem` records, one per delivery point. Each record's `native` field carries the raw dataset record for AddressBase and non-UK datasets, and is absent for the PAF family. Follow a dataset link for that record's complete field list. The array sits inside the standard `{ result, code, message }` envelope; see the [API reference](/docs/api/api-reference.md) for the wrapper format.

* `result` AddressListItem\[] Address (list endpoints)

  All addresses listed at the postcode.

  If Eircode is enabled, addresses for the Republic of Ireland will be returned in the English format.

  * `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` one of optional

    The raw dataset record backing this address. On these two endpoints it is returned for AddressBase (`ab`, `abp`) and non-UK datasets only, never for the PAF family. Use any other endpoint for a PAF native record.

    * 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)
