The Free JSON That Runs Britain: Five Public APIs Worth Building On
Photo by Photo by Emile Perron on Unsplash on Unsplash
Every so often a brief lands that sounds like six weeks of integration work and turns out to be an afternoon, purely because a public body already publishes the data as JSON and does not want your card details.
Britain is unusually good at this. Below are five feeds I keep coming back to — all free, all keyless or near enough — plus the boring bits: rate limits, uptime expectations, and what you actually do the morning a government API quietly changes shape.
1. postcodes.io — the one that pays for itself immediately
Handed a spreadsheet of four thousand customer addresses and asked to 'tidy it up'? This is your afternoon sorted. postcodes.io resolves a postcode to coordinates, local authority, ward and constituency, with no key and no sign-up.
const res = await fetch('https://api.postcodes.io/postcodes/BS1%205DD');
const { result } = await res.json();
console.log(result.admin_district, result.latitude, result.longitude);
Bulk lookups are a POST, and that is where it earns its keep:
await fetch('https://api.postcodes.io/postcodes', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ postcodes: ['SW1A 1AA', 'M1 1AE', 'EH1 1YZ'] })
});
There is reverse geocoding too, and a terminated-postcode flag which matters far more than you would expect for anything touching deliveries. The public instance carries no SLA and asks politely that you do not hammer it; the source is open, so if a client's revenue leans on it, run your own copy on a small box and sleep better.
2. Food Standards Agency — hygiene ratings for anything food-shaped
Building a directory, a booking form or an internal supplier list? The FSA publishes every rated food establishment in England, Wales and Northern Ireland.
const r = await fetch(
'https://api.ratings.food.gov.uk/Establishments?localAuthorityId=1&pageSize=100',
{ headers: { 'x-api-version': '2', Accept: 'application/json' } }
);
The header is the trap. Leave out x-api-version and you get an error rather than data, which is the sort of thing that eats a morning if you are skimming docs. Results are paged, so read meta.totalCount and loop properly instead of assuming one call gets everything.
3. TfL Unified API — live status without a licence fee
For anything London-facing, the Unified API gives you line status, arrival predictions and disruption detail.
const status = await fetch('https://api.tfl.gov.uk/Line/Mode/tube/Status');
const lines = await status.json();
console.log(lines.filter(l => l.lineStatuses[0].statusSeverity < 10).map(l => l.name));
It works without a key at low volume, but register for an app_key the moment you go anywhere near production, and keep that key server-side — it is a query parameter, which means it ends up in logs and referrers if you are careless. This is a status API, not a journey planner you should be reselling.
4. Environment Agency flood monitoring — the one with a social conscience
The flood-monitoring API gives you warnings, severity levels, station lists and river-level readings on roughly a fifteen-minute cadence. No key, real-time-ish, and genuinely useful for anything from a facilities dashboard to a village newsletter.
const floods = await fetch(
'https://environment.data.gov.uk/flood-monitoring/id/floods?minSeverity=3'
);
const active = await floods.json();
Severity three and above is the 'act now' tier, so filtering at the API rather than in your own code saves you both bytes and the risk of misreading the scale.
5. Companies House — the one that will outlive us all
Company search, filing history, officers, charges. Authentication is HTTP Basic with your API key as the username and a blank password:
const auth = Buffer.from(`${process.env.CH_KEY}:`).toString('base64');
const res = await fetch(
'https://api.company-information.service.gov.uk/company/09446231',
{ headers: { Authorization: `Basic ${auth}` } }
);
Two things to plan around. First, the rate limit is 600 requests per five minutes — generous until you decide to enrich ten thousand records in a loop. Second, identity verification for directors and people with significant control has changed what the officer data means, so do not build a KYC product on a stale assumption about what a name in that feed proves.
Rate limits, uptime and being a good citizen
None of these come with a contract. Treat every one of them as best-effort: cache aggressively, put a queue in front of bulk work, back off on 429 and 503 rather than retrying in a tight loop, and never let a third-party hiccup take your checkout page down with it. A twenty-four hour cache of postcode lookups is fine. A twenty-four hour cache of flood warnings is not.
When the shape changes overnight
Government APIs drift. Fields get deprecated, enums grow new values, a 200 comes back with an HTML error page because a proxy fell over. Three cheap defences:
- Wrap each API in one small client module. Nothing else in your codebase should know the URL exists.
- Validate on the way in. Check
content-typeis JSON, then check the two or three fields you actually depend on. Fail loudly and early. - Snapshot a real response in a fixture and assert against it in CI. When the shape moves, a test goes red instead of a client ringing you.
Ignore extra fields rather than rejecting them. You will get new keys you did not ask for, and that is a gift, not an error.
The wider point: for a great many UK briefs, the data already exists, already free, already maintained by someone on a public payroll. Charging a client for a licensed dataset when postcodes.io would have done is not diligence — it is just an invoice with extra steps.