TL;DR
Postcodes.io is the go-to free API for UK postcode data — pass any UK postcode (like SE14EG) and get back precise GPS coordinates, administrative boundaries, parish codes, census data, and nearby postcodes. It uses ONS (Office for National Statistics) open data and Ordnance Survey data. No API key, no rate limits, and includes useful extras like bulk lookup, random postcode generation, and postcode validation. Essential for any UK-focused app that needs to geolocate addresses.
Quick start: https://postcodes.io/postcodes/SE14EG
No API key needed — just make a request!
https://postcodes.io/postcodes/SE14EG
How to Use This API
1. Single Postcode Lookup
Returns full details for any valid UK postcode:
https://postcodes.io/postcodes/SE14EG
Returns: postcode, longitude, latitude, parliamentary constituency, NHS region, county, district, ward, and more.
2. Bulk Lookup (up to 100)
POST multiple postcodes in one request:
curl -X POST https://postcodes.io/postcodes \
-H "Content-Type: application/json" \
-d '{"postcodes": ["SW1A1AA", "EC2N4AY"]}'
3. Random Postcode Generator
Great for testing:
https://postcodes.io/random/postcodes
4. JavaScript — Map a Postcode
async function plotPostcode(postcode) {
const resp = await fetch(`https://postcodes.io/postcodes/${postcode}`);
const data = await resp.json();
const result = data.result;
console.log(`Postcode: ${result.postcode}`);
console.log(`Location: ${result.latitude}, ${result.longitude}`);
console.log(`Region: ${result.region}`);
console.log(`Constituency: ${result.parliamentary_constituency}`);
// Use coordinates with a mapping library
return { lat: result.latitude, lng: result.longitude };
}
plotPostcode('SE14EG');
5. Python — Validate Postcodes
import requests
postcodes = ['SE14EG', 'SW1A 1AA', 'INVALID']
for pc in postcodes:
resp = requests.get(f'https://postcodes.io/postcodes/{pc}/validate')
valid = resp.json()['result']
print(f"{pc}: {'Valid' if valid else 'Invalid'}")
Frequently Asked Questions
- What data does a postcode lookup return?
- Postcode, longitude/latitude, country, region, admin district, admin ward, parish, parliamentary constituency, CCG (NHS trust), NUTS codes, and census output area.
- Do I need an API key?
- No. Postcodes.io is completely free and open. No registration or authentication required for up to 30 requests/second.
- What are the rate limits?
- The API allows up to 30 requests per second from a single IP. For higher volumes, consider self-hosting the open-source code on GitHub.
- Does it support partial postcode search?
- Yes, you can use the
/postcodes/{outcode}endpoint for outward codes (e.g., "SE1") to get all postcodes in that area. - Can I look up by GPS coordinates?
- Yes, use
/postcodes?lon={lng}&lat={lat}to find the nearest postcode to a given location. Also supports/postcodes?lon=&lat=&radius=1000for nearby results. - How up-to-date is the postcode data?
- The database is updated regularly using the ONS Postcode Directory, typically within a few weeks of official releases.
API Details
- API URL
https://postcodes.io/postcodes/{postcode}- Documentation
- postcodes.io
- Category
- Geocoding
- Authentication
- Not Required
- Geographic Coverage
- United Kingdom — all UK postcodes
What You Can Build
- UK address autocomplete that validates postcodes in real-time on checkout forms
- Delivery route optimizer that calculates distances between postcode areas
- Property website that maps listings by postcode with neighborhood boundaries
- Local service finder showing nearby businesses by outward postcode
- Census data explorer that visualizes demographics by postcode area