Socket
Socket
Sign inDemoInstall

node-postcodes.io

Package Overview
Dependencies
4
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-postcodes.io

Postcodes.io - NodeJS Client/Wrapper


Version published
Weekly downloads
270
increased by63.64%
Maintainers
1
Install size
479 kB
Created
Weekly downloads
 

Readme

Source

Postcodes.io - NodeJS Client/Wrapper

JavaScript Style Guide NPM Build Status

An easy to use postcodes.io wrapper for NodeJS.

:arrow_forward: Install

Install the package with npm:

$ npm i node-postcodes.io

:clipboard: Usage

const postcodes = require('node-postcodes.io')

Lookup

http://postcodes.io/docs#Postcode-Lookup

// single
let result = await postcodes.lookup('PO123AA')

// batch
let result = await postcodes.lookup(['PO123AA', 'PO123AB'])

// batch (with filter)
let result = await postcodes.lookup(['PO123AA', 'PO123AB'], {
    filter: 'postcode,longitude,latitude'
})

Geo

http://postcodes.io/docs#Geocode-Postcode

Single
//
let result = await postcodes.geo(51.7923246977375,  0.629834723775309)

// with optional params
let result = await postcodes.geo(51.7923246977375,  0.629834723775309, {
    limit: 10,
    radius: 10,
    wideSearch: false
})
Batch
//
let result = await postcodes.geo([
    {
        "longitude": 0.629834723775309,
        "latitude": 51.7923246977375,
        "radius": 1000,
        "limit": 5
    },{
        "longitude": -2.49690382054704,
        "latitude": 53.5351312861402,
        "radius": 1000,
        "limit": 5
    }
])

// with optional params
let result = await postcodes.geo([
    {
        "longitude": 0.629834723775309,
        "latitude": 51.7923246977375,
        "radius": 1000,
        "limit": 5
    },{
        "longitude": -2.49690382054704,
        "latitude": 53.5351312861402,
        "radius": 1000,
        "limit": 5
    }
], {
    filter: 'postcode,longitude,latitude',
    wideSearch: false
})

Random

http://postcodes.io/docs#Geocode-Postcode

let result = await postcodes.random()

Validate

http://postcodes.io/docs#Postcode-Validation

let result = await postcodes.validate('PO123AA')

Nearest

http://postcodes.io/docs#Nearest-Postcode

let result = await postcodes.nearest('PO123AA')

// with optional params
let result = await postcodes.nearest('PO123AA', {
    radius: 1000,
    limit: 5
})

Autocomplete

http://postcodes.io/docs#Postcode-Autocomplete

let result = await postcodes.autocomplete('PO123AA')

// with optional params
let result = await postcodes.autocomplete('PO123AA', {
    limit: 5
})

Query

http://postcodes.io/docs#Postcode-Query

let result = await postcodes.query('PO123AA')

// with optional params
let result = await postcodes.query('PO123AA', {
    limit: 5
})

Terminated

http://postcodes.io/docs#Terminated

let result = await postcodes.terminated('PO123AA')

Outcodes

http://postcodes.io/docs#Show-Outcode

// lookup
let result = await postcodes.outcodes('PO33')
// nearest
let result = await postcodes.outcodes('PO3', {
    limit: 10,
    radius: 10
})
// nearest (lat, lng)
let result = await postcodes.outcodes(51.7923246977375,  0.629834723775309)

// with optional params
let result = await postcodes.outcodes(51.7923246977375,  0.629834723775309, {
    limit: 10,
    radius: 10
})

Places

http://postcodes.io/docs#Place-Lookup

// lookup
let result = await postcodes.places('osgb4000000074553605')

// query
let result = await postcodes.places('Ryde', {
    limit: 10
})

// random
let result = await postcodes.places()

:lock: Testing

Can see test results @ https://travis-ci.org/lcherone/node-postcodes.io, if you want to run them locally, your need install mocha, then run:

$ npm test

The MIT License (MIT). Please see License File for more information.

Keywords

FAQs

Last updated on 08 May 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc