Postcode lookup
What this does
Looks up a UK postcode and returns its latitude and longitude, constituent country, region, and a human-readable label. Other fetch.li endpoints accept postcodes directly; this one is for when you need the raw location data yourself.
Who it is for
- Forms that validate postcodes before submission
- Maps and delivery radius checks
- CRM enrichment (“where is this customer?”)
- Chaining into your own systems that need lat/lon
Try it
https://fetch.li/v1/uk/postcode?code=SW1A1AA
Other examples:
https://fetch.li/v1/uk/postcode?code=EH1%201AA
https://fetch.li/v1/uk/postcode?code=BT11AA
HTTP example
GET /v1/uk/postcode?code=SW1A1AA HTTP/1.1
Host: fetch.li
Accept: application/json
curl
curl -sS "https://fetch.li/v1/uk/postcode?code=SW1A1AA"
JavaScript fetch
const code = "SW1A1AA";
const response = await fetch(
`https://fetch.li/v1/uk/postcode?code=${encodeURIComponent(code)}`
);
const place = await response.json();
console.log(place.label, place.lat, place.lon);
Python requests
import requests
response = requests.get(
"https://fetch.li/v1/uk/postcode",
params={"code": "SW1A1AA"},
)
response.raise_for_status()
place = response.json()
print(place["label"], place["lat"], place["lon"])
Example JSON response
{
"code": "SW1A 1AA",
"code_compact": "SW1A1AA",
"lat": 51.5014,
"lon": -0.1419,
"label": "Westminster, London",
"admin_district": "Westminster",
"region": "London",
"country": "England",
"parliamentary_constituency": "Cities of London and Westminster"
}
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
code |
Yes | string | UK postcode, with or without space |
Errors that can happen
| HTTP | error.code |
When |
|---|---|---|
| 400 | invalid_body |
Missing code or malformed postcode format |
| 404 | not_found |
Postcode not found in the database |
| 429 | rate_limited |
Demo limit exceeded |
| 500 | internal |
Unexpected server error |
Demo
GET endpoints work without an API key on the public demo tier (60 calls per hour per IP). POST /v1/vibe/classify needs a key.
Try it
GET https://fetch.li/v1/uk/postcode
Answer
Response