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

wikigeocode

v1.5.0

Published

Simple utility to geocode an administrative location using the wikimedia APIs.

Downloads

10

Readme

wikigeocode

This tiny module performs the geocode of an administrative location (town, city, county, state, country, etc) using the wikimedia APIs, returning the wikipedia page title and the lat, lon coordinates if available, caching the results for an hour. For example:

> const {fetchSearchGeo} = require('wikigeocode')
> fetchSearchGeo('bogota').then(x => console.log(x))
> { pageid: 211271,
  ns: 0,
  title: 'Bogotá',
  coordinates:
   [ { lat: 4.71111111,
       lon: -74.07222222,
       primary: '',
       globe: 'earth' } ] }

The module only has an external node-fetch dependency to query the wikimedia APIs and Jest as dev dependency to run the tests.

Install

You can install with [npm]:

$ npm install --save wikigeocode

Usage

The module provides two main functions: fetchGeo to get the coordinates property from a wikipedia geographical entry and fetchExtract to get the summary (extract) of that particular page:

> const {fetchGeo, fetchExtra} = require('wikigeocode')
> fetchGeo('dublin').then(x => console.log(x))
> { pageid: 8504,
  ns: 0,
  title: 'Dublin',
  coordinates: [ { lat: 53.35, lon: -6.26666667, primary: '', globe: 'earth' } ] }

> fetchExtract('dublin').then(x => console.log(x))
>{ pageid: 8504,
  ns: 0,
  title: 'Dublin',
  extract: 'Dublin (; Irish: Baile Átha Cliath [ˈbˠalʲə aːhə ˈclʲiə; ˌbʲlʲaː ˈclʲiə]) is the capital of, and largest city in, Ireland ... '}

The previous two functions require the exact wikipedia page title. If you don't know the exact entry, you can use fetchSearchGeo and fetchSearchExtract to get the closest match to your query:

> const {fetchSearchGeo, fetchSearchExtra} = require('wikigeocode')
> fetchSearchGeo('londonderry').then(x => console.log(x))
> { pageid: 9055,
  ns: 0,
  title: 'Derry',
  coordinates: [ { lat: 54.9958, lon: -7.3074, primary: '', globe: 'earth' } ] }

> fetchSearchExtract('londonderry').then(x => console.log(x))
>{ pageid: 9055,
  ns: 0,
  title: 'Derry',
  extract: 'Derry, officially Londonderry (), is the second-largest city in Northern Ireland and the fourth-largest city on the island of Ireland. ...'}

License

Copyright © 2019, Juan Convers. Released under the MIT License.