Read product facts for free
This public endpoint requires no key and consumes no credits. A successful response is a JSON object with coverage.region, products, billing and developer links. An empty object indicates an unexpected response.
Unix shell
curl -fsS 'https://autopostcode.com/api/public/facts'PowerShell
Invoke-RestMethod -Uri 'https://autopostcode.com/api/public/facts'JavaScript (Node.js)
const response = await fetch('https://autopostcode.com/api/public/facts');
if (!response.ok) throw new Error('HTTP ' + response.status);
console.log(await response.json());Python
import json
from urllib.request import urlopen
with urlopen('https://autopostcode.com/api/public/facts', timeout=10) as response:
print(json.load(response))Make an authenticated lookup
Create a website and API key in Dashboard → API Keys. Store it as AUTOPOSTCODE_API_KEY in your server or service’s secret store. The key starts with ap_live_. Configure it on the machine that actually sends the request.
These examples use SW1A 1AA. A matched lookup consumes one credit. A no-match lookup returns HTTP 404 and consumes no credit when billing access is active.
The response example shows the shape with synthetic address data. Let the user choose a candidate or enter their address manually.
Unix shell
curl -sS --get 'https://autopostcode.com/api/public/lookup' --data-urlencode 'postcode=SW1A 1AA' -H "x-api-key: $AUTOPOSTCODE_API_KEY"PowerShell
Invoke-RestMethod -Uri 'https://autopostcode.com/api/public/lookup?postcode=SW1A%201AA' -Headers @{ 'x-api-key' = $env:AUTOPOSTCODE_API_KEY }JavaScript (Node.js)
const key = process.env.AUTOPOSTCODE_API_KEY;
if (!key) throw new Error('Configure AUTOPOSTCODE_API_KEY on this server');
const url = new URL('https://autopostcode.com/api/public/lookup');
url.searchParams.set('postcode', 'SW1A 1AA');
const response = await fetch(url, { headers: { 'x-api-key': key } });
const requestId = response.headers.get('x-request-id');
if (response.status === 404) console.log('Offer manual address entry');
else if (!response.ok) throw new Error('HTTP ' + response.status + ' (' + requestId + ')');
else console.log(await response.json());Python
import json, os
from urllib.error import HTTPError
from urllib.request import Request, urlopen
request = Request('https://autopostcode.com/api/public/lookup?postcode=SW1A%201AA',
headers={'x-api-key': os.environ['AUTOPOSTCODE_API_KEY']})
try:
with urlopen(request, timeout=15) as response:
print(json.load(response))
except HTTPError as error:
if error.code == 404:
print('Offer manual address entry')
else:
print(error.code, error.headers.get('X-Request-Id'))Illustrative response
[
{
"postcode": "SW1A 1AA",
"company": "",
"line1": "1 Example Street",
"line2": "",
"line3": "",
"dependent_locality": "",
"town": "LONDON",
"county": "Greater London",
"country": "United Kingdom",
"line1_full": "1 Example Street",
"formatted_address": "1 Example Street, LONDON, Greater London, SW1A 1AA"
}
]