To validate UK addresses via API, send a postcode or address to the AutoPostcode validation endpoint with your API key as a Bearer token; it checks the input against Royal Mail PAF and returns whether the address is deliverable, the correctly formatted version, and a UPRN. AutoPostcode validates against ~31M UK delivery points across ~1.8M postcodes.
How do I authenticate with the API?
Pass your API key as a Bearer token on every request, and keep it server-side:
const headers = {
Authorization: "Bearer " + process.env.AUTOPOSTCODE_KEY,
};How do I look up addresses for a postcode?
A lookup returns all PAF addresses for a postcode so the user can pick the exact one:
const res = await fetch(
"https://api.autopostcode.com/v1/lookup?postcode=SW1A1AA",
{ headers }
);
const { addresses } = await res.json();
// [{ line1, town, postcode, uprn }, ...]How do I validate a full address?
Validation confirms a supplied address is real and deliverable, and returns the clean form:
const res = await fetch("https://api.autopostcode.com/v1/validate", {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({ line1: "10 Downing St", postcode: "SW1A 2AA" }),
});
const { valid, formatted, uprn } = await res.json();How should I handle errors?
Branch on the HTTP status so failures are graceful and rate limits are respected:
| Status | Meaning | Action |
|---|---|---|
| 200 | Success | Use the result |
| 401 | Invalid key | Check the Bearer token |
| 429 | Rate limited | Back off and retry |
| 400 | Bad request | Validate your input |
What are the integration best practices?
- Keep the API key server-side, never in the browser
- Cache stable postcode lookups to cut repeat calls
- Store the UPRN as a permanent address identifier
- Soft-warn on failed validation instead of hard-blocking
See the endpoint-level UK address validation API overview, start fast with the API quickstart, and read every parameter in the REST API reference.
A modern, UK-first alternative
AutoPostcode uses the same Royal Mail PAF data as Loqate, Fetchify and Ideal Postcodes, with a clean REST API and an affordable per-lookup price — get your API key and integrate today.
Frequently asked questions
How do I validate UK addresses with an API?
Send the address or postcode to the AutoPostcode validation endpoint with your API key in the Authorization header. The API checks it against Royal Mail PAF and returns whether the address is deliverable, plus the correctly formatted version and a UPRN.
What data does a UK address validation API check against?
AutoPostcode validates against Royal Mail PAF, the authoritative UK address file covering ~31M delivery points across ~1.8M postcodes, so a passing address is a real, deliverable one.
What's the difference between validation and autocomplete?
Autocomplete helps a user find and select an address as they type; validation confirms a given address is real and deliverable. Most checkouts use autocomplete for entry and validation as a safety net on submit.
How do I authenticate with the address validation API?
Pass your API key as a Bearer token in the Authorization header of every request. Keep the key server-side so it never reaches the browser.
How should I handle validation errors and rate limits?
Check the HTTP status: 401 means an invalid key, 429 means you exceeded the rate limit, and 200 returns the result. Back off and retry on 429, and surface a helpful message on 4xx.
Can I validate addresses in bulk?
Yes. Loop your records through the validation endpoint server-side, respecting rate limits, to clean an existing database against Royal Mail PAF and flag undeliverable records.
Ready to get started?
Add Royal Mail PAF-verified UK address lookup to your site in minutes — start free, no card required.
