Giter VIP home page Giter VIP logo

postcodes.io's Introduction

Postcodes.io

UK postcode & geolocation API, serving up open data

CI codecov Dependency Status DOI

Query for UK postcodes and geolocations over HTTP.

Postcodes.io regularly ingests and serves the ONS Postcode Directory and Ordnance Survey Open Names datasets.

Features

  • Postcode lookup, resolve administrative and location data for postcodes and outward codes
  • Postcode search & autocomplete
  • Reverse geocode postcodes
  • Nearest postcode search
  • Terminated postcode search
  • Outward code lookup
  • Bulk postcode lookup and reverse geocoding

Usage

Quick Start

Start querying UK postcode data immediately on your local machine with Docker

docker-compose up

Docker Compose Demo

Testing

# Run entire test suite
make test

# Launch test application container and services, and run tests from container
make test-up
make test-shell
$api-container> npm test

License

MIT

postcodes.io's People

Contributors

acalderwood93 avatar adityamenon avatar aselinux avatar ashnaz87 avatar billinghamj avatar cblanc avatar charlieegan3 avatar dakkusingh avatar davedevelopment avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar evilstreak avatar g-wilson avatar goingdotin avatar grantshandy avatar greenkeeper[bot] avatar jamescun avatar kerv14 avatar mashedkeyboard avatar mdawsonuk avatar mfilip avatar michaeldipper-sky avatar mtmail avatar philmarc avatar semantic-release-bot avatar smithleej avatar spanglelabs avatar spdeepak avatar todrobbins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postcodes.io's Issues

Possible incorrect data for SN14 8JZ

SN14 8JZ returns data suggesting it is in South Gloucestershire. It's actually in Cold Ashton, Chippenham, Wiltshire. A quick check suggests this is generally true of SN14 codes.

Return additional data on /outcodes

Look into whether we can report additional data points for each outcode. Specifically:

  • Administrative district
  • Administrative ward
  • Any other data points which may be appropriate

/outcodes/:outcodes occasional null result for district/parish/county

E.g. /outcodes/br6

{
    "status": 200,
    "result": {
        "outcode": "BR6",
        "northings": "164987.835964912281",
        "eastings": "545678.044736842105",
        "longitude": 0.0912117066611443,
        "latitude": 51.3652763867838,
        "admin_ward": [
            "Farnborough and Crofton",
            "Darwin",
            "Orpington",
            "Halstead, Knockholt and Badgers Mount",
            "Bromley Common and Keston",
            "Cray Valley West",
            "Chelsfield and Pratts Bottom",
            "Petts Wood and Knoll",
            "Crockenhill and Well Hill",
            "Cray Valley East"
        ],
        "admin_district": [
            "Bromley",
            "Sevenoaks"
        ],
        "admin_county": [
            null,
            "Kent"
        ],
        "parish": [
            null,
            "Sevenoaks"
        ]
    }
}

importons : command not found

Hi sorry i'm new to node.js. I'm following the instructions in the read me but fail at the importons command with the error "importons: command not found". Do I have to do anything special with node?

Wider search radius

Any chance of getting a wider search radius for the search by lat lng. I'm making a map where dragging loads new search results for the new coordinates and I need to get a postcode to search by. Often it ends up outside of the 1km range of the nearest postcode. For example:

A453, Derby, Leicestershire DE73 8BB, UK
Latitude : 52.809403 | Longitude : -1.361275

Irish/BT postcodes GPS different to Google/Bing Map results

Great product and service. However the GPS results on Northern Ireland BT postcodes e.g. BT41 3UB are significantly different to those results from Google/Bing map search and other sites like http://irish.gridreferencefinder.com/, http://www.doogal.co.uk/ShowMap.php?postcode=BT41%203UB

e.g. the result from postcodes.io for BT41 3UB is
"longitude":-5.81387222553498,"latitude":54.8566885377204,

while the results from other sites are around the following point, which is about 40km's away.
lat:54.778698; lon:-6.437674

Appreciate that the postcodes.io lat,lon is likely calculated based on the irish grid reference provided in the ONSPD. Is this a problem at the source or the algorism?

Cheers!

Postcode Contribution

Can you let us know how we can contribute postcode data? A number of postcode areas for Scotland/Aberdeen are missing and I'd like to help fill in this gap.

Thanks

Bulk geocoding

Implement bulk geocoding with something like POST /postcodes and body checking

OSGR?

Not sure if there would be any other people who would find this useful, but you never know...
The data returned by the API already contains Eastings and Northings.

It is not hard from this to calculate the OSGR (for instance TQ 317 801), but it would be lovely not to have to do even that calculation!

In this case since each OS grid square is 100km, and TQ is 5 squares in, 1 up, than maps to 531700E, 180100N

Uncaught error: relation "postcode_index" already exists

Hi Chris, Apologies - I have got a little further, and I will write everything up a bit later to help others out who are not so familiar with postgres and node.js

I seem to be unable to progress past this error... When I visit the localhost/postcodes.io/about or any other page, the log shows a 404.

I tried npm test and the output finds a failure: "Uncaught error: relation "postcode_index" already exists". Any ideas?

daniel-spencers-macbook-pro:postcodes.io danspencer$ npm test

[email protected] test /Users/danspencer/Sites/postcodes.io
NODE_ENV=test mocha tests/ -R spec

Postcode API listening on port 8000

Pages routes
/
✓ should return 200 (645ms)
/docs
✓ should return 200 (191ms)
/about
✓ should return 200 (55ms)

Errors
404
✓ should return a 404 if page does not exist

Misc
✓ should return a favicon

Utils
Ping
✓ should pong

Utils with JSONP
Ping
✓ should pong

Postcodes routes
1) "before all" hook

7 passing (55s)
1 failing

  1. Postcodes routes "before all" hook:
    Uncaught error: relation "postcode_index" already exists
    at Connection.parseE (/Users/danspencer/Sites/postcodes.io/node_modules/pg/lib/connection.js:561:11)
    at Connection.parseMessage (/Users/danspencer/Sites/postcodes.io/node_modules/pg/lib/connection.js:390:17)
    at null. (/Users/danspencer/Sites/postcodes.io/node_modules/pg/lib/connection.js:92:20)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket. (stream_readable.js:746:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable
    (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)
    at TCP.onread (net.js:528:21)

npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0

Road name and House No.

If it possible to include a list of Road names and House No.'s that the post code could belong to? This would make live pop search for address possible, saving end users time and also helping keep the incoming data accurate

Possible Encoding Issues: LL65 2UH

This might not actually be an issue on your side but I thought I would flag it anyway. Take a look at the parliamentary_constituency for LL65 2UH

It should be: Ynys Môn

But the encoding is incorrect. Not sure if this is a data source issues or your importing issue, or heaven forbid my own processing issue.

JSONP Error Workaround

Return all JSONP requests that result in errors with HTTP code of 200. This will allow browser based clients to handle non-200 responses via the response codes

Inconsistent response when there are two "nearest" postcodes

Hi there,

Identified the above issue when using the following as an input:
{"lat":53.480412,"long":-2.223332}

Output 1: M4 6DN
"longitude": -2.2234081205581,
"latitude": 53.4804876316574,

Output 2: M4 6DT
"longitude": -2.2234081205581,
"latitude": 53.4804876316574,

While both are valid, the response from the server is inconsistent as sometimes I get the former and sometimes I get the latter as the first element in the list.

Is there something I can do on my side to ensure the response is consistent? Is it an issue on your side?

Jonathan

Upgrade and update instructions

Hi,

Thanks very much for this project, been using it for about a year now and everything is great.

However, one of our users has reported some missing postcodes so I went to see about finally updating the postcode database...

First issue, there are no update instructions, only creating a new database from scratch. Updating using the setup script doesn't work because it throws errors when the database already exists.

I noticed the latest master has a bin/update_ons.js, so I went and updated to the latest master.

Unfortunately, this now gives error: relation "districts" does not exist. So clearly the database structure has changed a bit. Fair enough, but how do I fix this? Is there a migration script somewhere or do I have to delete the whole database and start from scratch?

Please could we get some clear instructions on how to update the postcodes data, and how to upgrade the server. Is it possible to safely upgrade a live server somehow? Or is the only option to drop everything and rebuild from scratch?

Thanks.

Wrongly returns a 404 status code

if you go to http://api.postcodes.io/postcodes/s62%205ty it correctly returns a result of 'postcode not found' but has a 404 status code. Not sure if this is just a mistake or a misunderstanding of what a 404 status code means.

If the communication with the server was successful, regardless of whether results were found it should return a 200 status code.

Allow search by parish

I realise this is bit specific as a request, but would it be possible to return all the postcodes in a given parish somehow? As an example I'm looking at the Ewhurst parish (E04009613).

make it clear commercial use of Northern Ireland data is not allowed

As pointed out on the /about page
"Great Britain postcode data may be used under the terms of the OS OpenData licence. Northern Ireland postcode data may be used under the terms of the ONSPD licence"

The ONSPD licence https://www.ons.gov.uk/methodology/geography/licences doesn't allow commercial use
"If you also use the Northern Ireland data (postcodes starting with “BT”), you need a separate licence for commercial use direct from Land and Property Services. We only issue a Northern Ireland End User Licence (for internal business use only) with the data."

Personally I don't like their terms, especially labeling it open, but it's a important enough restriction to mention it to users of the service.

how to install on Ubuntu 16 LTS

Hi,

The installation instructions are among the best I've seen considering how many dependencies get installed. The instructions from 17 Oct 2014 cover Ubuntu 14. I've installed it on Ubuntu 16 in a virtual machine and below are my notes should you ever want to update the instructions. I think that's optional but it might safe you an hour or to debugging.

  • Running apt-get upgrade grub asks which partitions to install bootrecords on. Sadly the question is interactive (even when setting export DEBIAN_FRONTEND=noninteractive) breaking any automated builds. A solution is executing echo "set grub-pc/install_devices /dev/sda" | sudo debconf-communicate before apt-get upgrade.
  • Curl needs to be installed sudo apt-get install curl
  • python-software-properties python is not required. I ran a successful full build without those.
  • same for pgadmin3
  • Instead of node 4 I installed node 6 (currently 6.7.0) like this:
# http://askubuntu.com/revisions/786279/6
sudo touch /etc/apt/sources.list.d/nodesource.list
echo "deb https://deb.nodesource.com/node_6.x xenial main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/node_6.x xenial main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
sudo apt-get update -qq
sudo apt-get install nodejs
  • Instead of Postgres 9.3 I installed 9.5.
sudo apt-get install -y postgresql-9.5-postgis-2.2 postgresql-contrib-9.5

Ubuntu sources already know about 9.5, there's no need to patch the /etc/apt/sources.list any more.

  • buynan-syslog has a resolved issue (TritonDataCenter/node-bunyan-syslog#39) with node 6 that requires it to be installed from github master instead of npm. Both have the same version (0.3.1) which is confusing. iconv needs to be updated though (bnoordhuis/node-iconv#157), maybe even replacing with iconf-lite might be an option. Running these steps works but I see that as temporary fix only.
cd postcodes.io/
npm install mcavage/node-bunyan-syslog
npm install [email protected] --save
npm install
  • there's a warning npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.