UK Postcode API serving up Open Data
JavaScript HTML CSS Shell
Latest commit e8a2331 Jan 24, 2017 @cblanc cblanc committed on GitHub Merge pull request #98 from charlieegan3/patch-1
Correct ruby gem link.
Failed to load latest commit information.
app Update noticeboard Jan 4, 2017
bin Add nuts etl script and new codes Nov 28, 2016
config Expanded CORS preflight headers Jun 17, 2016
data Remove space on constituency fixes #96 Jan 9, 2017
public Added link to critical service information emails Feb 1, 2016
tests Listen for clientError Nov 18, 2016
.travis.yml Add log file for travis Nov 18, 2016 Correct ruby gem link. Jan 23, 2017
latest Update ons for Nov 2016 Nov 28, 2016
npm-shrinkwrap.json Peg bunyan-syslog depedenecy to frozen ideal-postcodes repo Nov 18, 2016
package.json Bump to 3.0.3 Nov 29, 2016
server.js Build Status

Query for UK postcodes and geolocations over HTTP. uses the Office for National Statistics Postcode Directory.

Documentation can be found at


Please make sure you have the following available:

We also have an end-to-end guide to install on a fresh virtual machine in the wiki.

Install & Download Data & Run

Download and install

$ git clone

$ cd && npm install

Configure Postgres and Seed Database is packaged with a script to setup and download the ONS Postcode Directory. To run this, navigate into the repository directory and run,

$ npm run setup

This script will prompt you for Postgres superuser credentials. This privilege is required to create a new user, database, extensions and then to load the data. For the security conscious, you can find out how this works by reading our installation notes and the script itself. Other install methods are available but require a bit of extra work.

You can change the Postgres username/password yourself but you will need to update 'config/config.js' with the relevant credentials.

The import process takes around 10 minutes to complete.

Run it

node server.js // Default environment is development


$ npm run setup_test_db # create test database

$ npm test

Upgrade Notes & Changelog

Any changes, including backwards incompatible changes will be listed here


  • Updated latest pg_dump for Nov 2016 ONSPD
  • Updated NUTS GSS codes
  • Added support for Node.js 6.9


  • Updated latest pg_dump for Aug 2016 ONSPD


  • Added some missing GSS codes. Fix import script for Aug 2016 ONSPD


  • Drop support for node.js 0.10 and 0.12


  • Expanded accept headers and HTTP methods in CORS preflight requests


  • Updated dataset to February 2016

External Libraries

  1. Java Library by Deepak Sunanda Prabhakar

  2. PHP Libraries

  3. Ruby Library by James Ruston

  4. Node.JS Library by billinghamj

  5. Python Library by Gokhan Karadas

  6. C# Library by Mark Embling

  7. R Library by Eryk Walczak. Read the blog post.

  8. Google Sheets Addon by Ed Patrick