AutoPostcode
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"

Validation APIs

Beyond postcode lookup, the same API key and x-api-key header unlock email, phone and bank account validation. All products draw from one shared credit balance — cost per call is shown below. Every endpoint accepts GET (query string) or POST (JSON body).

Address auto-complete

1 credit (per request that returns suggestions)
GET https://autopostcode.com/api/public/autocomplete

Parameters: q (required, min 2 chars) — full or partial postcode

request
curl "https://autopostcode.com/api/public/autocomplete?q=SW1A%201AA" \
  -H "x-api-key: ap_live_xxxxxxxxxxxxxxxx"
response.json
{
  "query": "SW1A 1AA",
  "count": 2,
  "suggestions": [
    {
      "suggestion": "10 Downing Street, London, Greater London, SW1A 2AA",
      "postcode": "SW1A 2AA",
      "line1": "10 Downing Street",
      "line2": "",
      "line3": "",
      "town": "London",
      "county": "Greater London",
      "country": "United Kingdom"
    }
  ],
  "credits_remaining": 1584
}

Email validation

1 credit
GET https://autopostcode.com/api/public/validate-email

Parameters: email (required)

request
curl "https://autopostcode.com/api/public/validate-email?email=jane@example.com" \
  -H "x-api-key: ap_live_xxxxxxxxxxxxxxxx"
response.json
{
  "email": "jane@example.com",
  "verdict": "valid",          // valid | invalid | risky | unknown
  "result": "valid",
  "flags": [],
  "suggested_correction": null,
  "credits_used": 1,
  "credits_remaining": 1583
}

Phone validation

1 credit (format) · 2 credits with live=true
GET https://autopostcode.com/api/public/validate-phone

Parameters: phone (required) · country (default GB) · live (true for HLR network check)

request
curl "https://autopostcode.com/api/public/validate-phone?phone=07700900123&country=GB&live=true" \
  -H "x-api-key: ap_live_xxxxxxxxxxxxxxxx"
response.json
{
  "phone": "+447700900123",
  "valid": true,
  "verdict": "valid",
  "country": "GB",
  "line_type": "MOBILE",
  "national_format": "07700 900123",
  "international_format": "+44 7700 900123",
  "live": { "connectivity": "CONNECTED", "carrier": "EE", "ported": false },
  "credits_used": 2,
  "credits_remaining": 1581
}

Bank account validation

1 credit (modulus) · 10 credits with cop=true
GET https://autopostcode.com/api/public/validate-bank

Parameters: sort_code (required) · account_number (required) · name + cop=true for Confirmation of Payee · type (personal|business)

request
curl "https://autopostcode.com/api/public/validate-bank?sort_code=07-00-93&account_number=33333334" \
  -H "x-api-key: ap_live_xxxxxxxxxxxxxxxx"
response.json
{
  "valid": true,
  "verdict": "valid",
  "sort_code": "070093",
  "account_number": "33333334",
  "confirmation_of_payee": null,   // { match, account_name } when cop=true
  "credits_used": 1,
  "credits_remaining": 1580
}

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.