Skip to main content

Postcode lookup

postcodes returns every address for a UK postcode. Searches ignore case and spacing, so sw1a2aa finds SW1A 2AA.

How do I look up a postcode?​

Pass the postcode as path.postcode. The addresses sit in data.result.

postcode-lookup.tsts
import { createIdpcClient, postcodes } from "@ideal-postcodes/sdk";

const client = createIdpcClient({ apiKey: "ak_test" });
const { data } = await postcodes({
client,
path: { postcode: "SW1A 2AA" },
});
console.log(data.result);

What if the postcode does not exist?​

The call throws an ApiError with status 404 and code 4040, and costs no lookup. The error body carries up to 5 suggestions, the closest matching postcodes. If there are fewer than 3, the right postcode is likely among them. See result objects to read them without a try block.

What does a postcode lookup cost?​

A postcode that returns addresses costs one lookup. Your key needs one of PAF, Multiple Residence, Not Yet Built, PAF Alias, PAF Welsh, AddressBase or AddressBase Premium for UK postcodes.

What about postcodes with more than 100 addresses?​

The API returns 100 addresses per page. Pass query: { page: 1 } for the next 100. Only a small number of postcodes need it.

See postcodes for Irish, Dutch and Singapore postcodes. The API reference documents the response.

Try it​

Enter a browser API key and select Start example. Requests use your account. Do not enter a Management Key.

Loading...