npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unlock-places

v0.0.2

Published

A node.js module to make interfacing with the Unlock Places API easy.

Downloads

3

Readme

unlockplaces-node

About

A node.js module to make interfacing with the Unlock Places API by EDINA easy. The API documentation is available here.

Install

Install as a standard npm module.

  $ npm install unlock-places

Usage

The most straight forward use case is to require the module and simply call methods that are exposed by the API as explained in the docs.

Each request to the API will by default use the 'unlock' gazetteer and 'json' as the format option. These can be overridden by using setResponseFormat, setGazetteer, setDefaults or by creating a new Unlock object and providing defaults to the constructor.

  var unlock = require('unlock-places');

  // Do a loaction search
  unlock.search({
    name: 'dublin',
    country: 'ireland'
  }, function(err, res) {
    // Assuming we're using json as format
    res = JSON.parse(res);
  });

An alternative use case might be to create multiple Unlock Places objects and use them for different purposes. This will allow you to apply defualts to each request without applying them as defaults to the originally required Unlock Places object.

  var unlock = require('unlock-places');

  // Each request using this object will include the 'country' parameter
  var useIreland = new unlock.Class({
    country: 'ireland'
  });

  // Do a search for places named 'Dublin' in ireland and use the 'os' gazetteer
  useIreland.search({
    name: 'dublin',
    gazetteer: 'os'
  }, function(err, res) {
    // Assuming we're using json as format
    res = JSON.parse(res);
  });

Documentation


Set the default response format for each API request. Can be 'json', 'xml', 'kml' or 'txt'.


Returns the default response format to use.


Set the default gazetteer for each API request. Can be 'unlock', 'os' or 'naturalearth'


Returns the default gazetteer to use for each request.


Set default parameters to add to each request. For example:

  var places = require('unlock-places');

  // All of these are optional. Old defaults will be erased.
  places.setDefaults({
    format: 'xml',
    name: 'london',
    gazetteer: 'naturalearth'
  });

Return the defaults being used in each request.


Run a locations search against the API. Params is an object that contains any items to add to the request querystring. Any params included that conflict those in defaults will override the default setting.

  var places = require('unlock-places');

  // All of these are optional. Old defaults will be erased.
  places.setDefaults({
    format: 'xml',
    name: 'london',
    gazetteer: 'naturalearth'
  });

  // Do a request but override the xml response format default.
  places.search({
    name: 'paris',
    format: 'txt'
  });

Run a footprintLookup against the API. The params object must contain an 'id' parameter.


Run a featureLookup against the API. The params object must contain an 'id' parameter.


Run a search against the API and returns a single result only.


Returns the supported feature types for the given params.