0

Need the functionality on a site I'm making to get a user's electoral ward & constituency from a UK postcode which has been entered.

I have been using https://www.uk-postcodes.com/ where you'd make a simple file_get_contents() call like https://www.uk-postcodes.com/postcode/postcode.json but that site has recently gone down (CloudFlare Bad Gateway) - which I always knew was a risk of using an external service, but I took it anyway.

How can I get this same information directly from the ONS website? I honestly can't find anything related to this at all, never mind where to make this call.

One thing to note: I don't want to have to include a whole library for this. I'd prefer a much more minimalistic approach to this.

I'd be very grateful for any advice or help on this.

Chris98
  • 567
  • 1
  • 4
  • 16

1 Answers1

0

This data is in the quarterly ONS Postcode Directory, which you can download from here:

http://geoportal.statistics.gov.uk

The latest version is February 2017:

http://ons.maps.arcgis.com/home/item.html?id=dfa0ff74981b4b228d2030d852f0b14a

Dan Winchester
  • 324
  • 1
  • 7