βΆ Cloudflare Worker code (deploy this to enable live data)
1. Go to workers.cloudflare.com β Create Worker
2. Paste this code, replacing YOUR_EMAIL and YOUR_API_KEY
3. Deploy and copy the Worker URL into the field above
// Cloudflare Worker β DEC / EPC API Proxy
// Replace these with your credentials from get-energy-performance-data.communities.gov.uk
const EMAIL = 'YOUR_EMAIL@example.com';
const API_KEY = 'YOUR_API_KEY';
const TOKEN = btoa(`${EMAIL}:${API_KEY}`);
// New API base (as of June 2026)
const API_BASE = 'https://epc.opendatacommunities.org/api/v1';
// If the above stops working, try the new service:
// const API_BASE = 'https://get-energy-performance-data.communities.gov.uk/api/v1';
const CORS = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type',
};
export default {
async fetch(request) {
if (request.method === 'OPTIONS') return new Response(null, { headers: CORS });
const url = new URL(request.url);
const type = url.searchParams.get('_type') || 'display';
url.searchParams.delete('_type');
const apiUrl = `${API_BASE}/${type}/search?${url.searchParams.toString()}`;
const resp = await fetch(apiUrl, {
headers: { 'Authorization': `Basic ${TOKEN}`, 'Accept': 'application/json' }
});
const body = await resp.text();
return new Response(body, {
status: resp.status,
headers: { ...CORS, 'Content-Type': 'application/json' }
});
}
};