Postcodes.io API: List nearby postcodes
Lists UK postcodes nearest to a postcode or named place, with distance, ward, council and coordinates. For places sharing a name, a city or town is preferred.
Unofficial. Not affiliated with or endorsed by Postcodes.io.
Inputs
Values from the run on Oct 23, 2026, shown under Output.
- Near, required
near A UK postcode or place name, for example SW1A 1AA or Oxford.
SW1A 1AA
- Max Results optional
max_results Maximum number of nearest postcodes, for example 10.
10 (default)
Whole number from 1 to 100.
- Radius (metres) optional
radius_metres Maximum distance in metres from the postcode or place, for example 1000.
1000 (default)
Whole number from 1 to 2000.
Input as JSON
{ "near": "SW1A 1AA"}Output
{ "postcodes": [ { "ward": "St James's", "latitude": 51.50101, "page_url": "https://postcodes.io/postcodes/SW1A%201AA" , "postcode": "SW1A 1AA", "longitude": -0.141563, "local_council": "Westminster", "distance_metres": 0 }, { "ward": "St James's", "latitude": 51.499933, "page_url": "https://postcodes.io/postcodes/SW1E%206LA" , "postcode": "SW1E 6LA", "longitude": -0.141117, "local_council": "Westminster", "distance_metres": 123.67233656624896 }, { "ward": "St James's", "latitude": 51.499738, "page_url": "https://postcodes.io/postcodes/SW1E%206AY" , "postcode": "SW1E 6AY", "longitude": -0.140736, "local_council": "Westminster", "distance_metres": 152.5853742672548 } ]}Code
curl https://api.fous.com/v1/runs \ -H "Authorization: Bearer $FOUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"method":"postcodes.io/list_nearby_postcodes","input":{"near":"SW1A 1AA"}}' # Save as fous.py, then run: python3 fous.pyimport json, os, timefrom urllib.error import HTTPErrorfrom urllib.request import Request, urlopenAPI = "https://api.fous.com/v1/runs" KEY = os.environ["FOUS_API_KEY"]HEADERS = { "Authorization": f"Bearer {KEY}", "Content-Type": "application/json" ,}def call(url, body=None): data = json.dumps(body).encode() if body else None request = Request(url, data, HEADERS) try: with urlopen(request, timeout=120) as r: return r.status, json.load(r) except HTTPError as error: message = json.load(error)["error"]["message"] raise RuntimeError(message) from errorstatus, run = call(API, { "method": "postcodes.io/list_nearby_postcodes" , "input": { "near": "SW1A 1AA" }})# 202: still going after 30 s. Ask again until it ends.while status == 202: time.sleep(2) status, run = call(f"{API}/{run['id']}")print(json.dumps(run["data"], indent=2))// Save as fous.mjs, then run: node fous.mjsconst api = "https://api.fous.com/v1/runs" ;const headers = { Authorization: `Bearer ${process.env.FOUS_API_KEY}`, "Content-Type": "application/json" ,};let response = await fetch(api, { method: "POST", headers, body: JSON.stringify({ "method": "postcodes.io/list_nearby_postcodes" , "input": { "near": "SW1A 1AA" } }), signal: AbortSignal.timeout(120_000),});let run = await response.json();// 202: still going after 30 s. Ask again until it ends.while (response.status === 202) { await new Promise((done) => setTimeout(done, 2_000)); response = await fetch(`${api}/${run.id}`, { headers }); run = await response.json();}if (!response.ok) throw new Error(run.error.message);console.log(run.data);# Connect your agent to Fous once, over MCP (Streamable HTTP):# https://api.fous.com/mcp# Set FOUS_API_KEY first: create a key at https://app.fous.com/keys.# Claude Codeclaude mcp add \ --scope user \ --transport http fous https://api.fous.com/mcp \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Codexcodex mcp add fous \ --url https://api.fous.com/mcp \ --bearer-token-env-var FOUS_API_KEY# Cursor, VS Code, Windsurf, Cline and morenpx -y add-mcp https://api.fous.com/mcp -g -n fous \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Then ask your agent:# "Use Fous to run postcodes.io/list_nearby_postcodes# with {"near":"SW1A 1AA"}"Over HTTP, the answer’s data holds the output. A run still going after 30 seconds answers 202 with its id: ask GET /v1/runs/{id} until it ends.
Schema
Input schema
{ "type": "object", "required": [ "near" ], "properties": { "near": { "type": "string", "minLength": 1, "description": "A UK postcode or place name, for example SW1A 1AA or Oxford." }, "max_results": { "type": "integer", "default": 10, "maximum": 100, "minimum": 1, "description": "Maximum number of nearest postcodes, for example 10." }, "radius_metres": { "type": "integer", "default": 1000, "maximum": 2000, "minimum": 1, "description": "Maximum distance in metres from the postcode or place, for example 1000." } }}Output schema
{ "type": "object", "required": [ "postcodes" ], "properties": { "postcodes": { "type": "array", "items": { "type": "object", "properties": { "ward": { "type": [ "string", "null" ] }, "latitude": { "type": [ "number", "null" ] }, "page_url": { "type": "string" }, "postcode": { "type": "string" }, "longitude": { "type": [ "number", "null" ] }, "local_council": { "type": [ "string", "null" ] }, "distance_metres": { "type": "number" } } }, "description": "Postcodes ordered nearest first." } }}- Price
- 1 credit per completed run (1¢ with pay as you go); failed runs are free.
- Method
postcodes.io/list_nearby_postcodes- Returns
- postcode, distance, ward, council, latitude, longitude, page URL
Use it from your agent
Give your agent this line. It reads SKILL.md, gets a Fous API key and connects the Fous MCP server. Its run then takes the method postcodes.io/list_nearby_postcodes with the inputs above.
Ask your agent
- What postcodes are within 500 metres of SW1A 1AA, and which councils do they belong to?
- Give me the 15 closest UK postcodes to Oxford with their wards and coordinates.
- Find nearby postcodes around Leeds city centre within a 1500 metre radius, including distances.
- I need the nearest postcodes to M1 1AE on postcodes.io, up to 20 results, with latitude and longitude.
- List the postcodes within 800 metres of Bristol Temple Meads showing ward and council names.
See more
All Postcodes.io methodsLooks up a UK postcode on Postcodes.io, including its location, administrative areas and whether it is still in use. Retired postcodes return location and retirement year only.
postcodes.io/get_postcodeGets crimes reported within one mile of a UK postcode or place in England, Wales or Northern Ireland for a month (latest published by default), with category totals, up to 100 sampled incidents, the previous month's total and the local police.uk crime-map link.
data.police.uk/get_crimes_near_postcodeFinds the neighbourhood policing team for a UK postcode (England, Wales, Northern Ireland) with its force, contacts, officers, priorities and upcoming events.
police.uk/get_neighbourhood_teamFind nearby NHS service listings from a UK postcode or town, nearest first. NHS service search covers England; urgent_care returns A&E listings. Hours, patient availability and websites are null when not shown.
nhs.uk/search_nearby_servicesFinds Open Charge Map charging locations near an address, city, or postcode, nearest first.
openchargemap.org/search_chargersFinds Indian post offices matching a place name, with PIN codes, branch types, delivery statuses, districts and states. Optionally narrows by state or district.
postalpincode.in/search_pin_codesFinds Starbucks cafés near a city, address or ZIP code, nearest first, with whether each is open now, today's local hours and amenities; optionally only cafés open now.
starbucks.com/search_storesFinds GreatSchools schools within 5 miles of a US address, city or ZIP code. Results can be filtered by grade and school type and sorted by distance or rating.
greatschools.org/search_schools