# UPRN lookup

Pass a UPRN to `addresses` as the `uprn` filter to retrieve the address it identifies. The UPRN (Unique Property Reference Number) is the number UK local authorities assign to each property and Ordnance Survey maintains.

## Look up a UPRN

Call `addresses` with `uprn` and no `query`.

uprn-lookup.tsts

```ts
import { createIdpcClient, addresses } from "@ideal-postcodes/sdk";

const client = createIdpcClient({ apiKey: "ak_test" });
const { data } = await addresses({
  client,
  query: { uprn: 50002012147 },
});
const [address] = data.result.hits;
console.log(address?.line_1, address?.post_town, address?.postcode);
```

The `uprn` filter takes one UPRN per request. It does not accept a comma separated list.

## Result

The address sits in `result.hits`. This response is trimmed to the identifiers and postal fields:

```json
{
  "code": 2000,
  "message": "Success",
  "result": {
    "hits": [
      {
        "dataset": "paf",
        "uprn": "50002012147",
        "udprn": 2670849,
        "line_1": "9 Malyons Road",
        "line_2": "Hextable",
        "post_town": "Swanley",
        "postcode": "BR8 7RE",
        "country": "England"
      }
    ]
  }
}
```

`dataset` names the source of the address, such as `paf` for Royal Mail's Postcode Address File. `udprn` is Royal Mail's delivery point reference for the same premise.

The API returns `uprn` as a string. A UPRN runs to 12 digits, so store it as text or as a 64-bit integer. Spreadsheet applications such as Excel corrupt values of that length.

## Addresses with a UPRN

UK addresses carry a UPRN, taken from Ordnance Survey AddressBase. A small number of Great Britain addresses return an empty string while AddressBase catches up, as do addresses outside the UK. Multiple Residence premises share the UPRN of their parent premise.

## Cost

A request that returns an address costs one lookup. An empty result costs nothing. Your key needs at least one of PAF, Multiple Residence, Not Yet Built, PAF Alias, PAF Welsh, AddressBase or AddressBase Premium, or the API rejects the request.

See [`addresses`](/docs/sdks/typescript/endpoints/addresses.md) for every parameter and the response type.
