Developer API

Call the lookup API from any web app

Not on WordPress? Use plain JavaScript to fetch verified UK address JSON. Same endpoint, same API key authentication and same request format as our WooCommerce plugin.

1. Get your API key

Log in to your dashboard, add a website and mint a live API key (it starts with ap_live_). The same key powers both the plugin and custom apps.

2. Drop in the JavaScript

Paste the snippet below into your app, set your endpoint and API key, then call lookupPostcode() wherever you need addresses.

3. Render the raw JSON

The API returns an array of structured address objects — map them into your own dropdown, form fields or autocomplete.

Endpoint & authentication

One GET request, authenticated with your website API key in the x-api-key header.

Method
GET
Auth header
x-api-key: ap_live_…
Endpoint
https://autopostcode.com/api/public/lookup?postcode=BH31%206EL

JavaScript example

Copy this into your custom app, swap in your API key and call lookupPostcode().

lookup.js
// AutoPostcode — UK address lookup from any custom web app.
// Reuses the exact endpoint, auth header and request format the
// WordPress/WooCommerce plugin uses. Returns raw addresses JSON.

const APC_ENDPOINT = "https://autopostcode.com/api/public/lookup";
const APC_API_KEY = "ap_live_xxxxxxxxxxxxxxxx"; // your website API key

async function lookupPostcode(postcode) {
  const url = APC_ENDPOINT + "?postcode=" + encodeURIComponent(postcode);

  const res = await fetch(url, {
    method: "GET",
    headers: {
      "x-api-key": APC_API_KEY,
    },
  });

  if (!res.ok) {
    const err = await res.json().catch(() => ({}));
    throw new Error(err.error || "Lookup failed (" + res.status + ")");
  }

  // Raw array of address objects.
  return res.json();
}

// Usage
lookupPostcode("BH31 6EL")
  .then((addresses) => console.log(addresses))
  .catch((e) => console.error(e));

Example response

addresses.json
[
  {
    "postcode": "BH31 6EL",
    "line1": "1 Example Street",
    "line2": "",
    "line3": "",
    "town": "Verwood",
    "county": "Dorset",
    "country": "United Kingdom"
  }
]

Prefer cURL?

terminal
curl "https://autopostcode.com/api/public/lookup?postcode=BH31%206EL" \
  -H "x-api-key: ap_live_xxxxxxxxxxxxxxxx"

Keep your key safe

Your ap_live_ key is scoped to a single website and every lookup is logged against it. Use a key per site so usage and access stay isolated, and rotate a key any time from your dashboard if it leaks.

Ready to build?

Create an account, mint a key and start returning verified UK addresses in minutes.