Integration · Code
UK postcode lookup in Python
A requests.get with your key returns everything about a postcode; a POST checks up to 100 at once. No SDK needed.
Get a free key10,000 lookups a month free · no card
Set it up
- 1Get a free key at /developers.
- 2pip install requests (or use httpx).
- 3Call the endpoint; read the data key.
The code
import os, requests
KEY = {"x-api-key": os.environ["CLEAR_KEY"]}
d = requests.get("https://api.clearpostcode.co.uk/v1/postcodes/SW1A 1AA", headers=KEY, timeout=5).json()["data"]
print(d["postcode"], d["local_authority"]["name"], d["location"]["latitude"])
# up to 100 at once
rows = requests.post("https://api.clearpostcode.co.uk/v1/postcodes", headers=KEY, json={"postcodes": ["M1 1AE", "LS6 9FE"]}, timeout=10).json()["data"]Questions
Python questions
How do I check a CSV of postcodes?
Read it with csv or pandas, send 100 postcodes per POST, and write the fields you need back out.