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

city

v1.0.4

Published

The City API returns the city from a latitude and longitude using spatial mapping and data anlysis.

Downloads

31

Readme

City

The City API gets a city or closest city from a latitude and longitude.

It uses an algorithim that utilises spatial mapping and sophisticated data analysis to give you a blazing fast and accurate response from over 150,000 cities from every country across the globe.

This package requires an API key which can be generated Here.

Installation

npm i city --save

Usage

const city = require( 'city' )

//Using Promises
city.get( latitude, longitude, size, apiKey )
    .then( location => {
      console.log( location )
    })
    .catch( e => console.log( e ))
    
//Async await
const location = await city.get( latitude, longitude, size, apiKey )

City Sizes

| Size | Description
| ----------- | -------------------------- | |NULL | This will search through every city of every size |0 | Major Cities, 1m+ population |1 | Big Cities, 250k - 1m population |2 | Medium Cities, 10k - 250k population |3 | Small cities, under 10k population

Demos

city.get( 35.4526317, 139.4546863, 0, apiKey )
//Response
{
    city: 'Yokohama'.
    country: 'JP',
    population: 3574443,
    distance: 17.823109463333083
}

city.get( 42.34133262, -83.05576000, 1, apiKey )
//Response
{
    city: 'Detroit'.
    country: 'US',
    population: 677116,
    distance: 1.3745663787473823
}

Response

| Property | Description | ----------- | -------------------- | |city| The city name. |country | The 2 letter country code which the city is located. |population | The last updated population of that city. |distance | The distance between the user and city center in km.

Errors

| Status | Error | Description | ----------- | -------------------- | ---------------------------------- | |422 |API KEY NOT FOUND | You need to pass your API key as a parameter. You can get one Here. |422 |INVALID API KEY | Your key is invalid or badly formatted. |422 |INVALID SIZE | Your size parameter is invalid. |402 |NO CREDITS REMAINING | You need to purchase more credits for your key. You can do that Here.| Icons related to the business type |422 |INVALID COORDINATES | Missing or invalid latitude/ longitude.

Documentation

This is a brand new API launced in February 2021. Full Documentation will be here soon.

Click Here to see the full documentation

Use cases

  • Location based social media
  • Dating services
  • Profiles
  • Location based games
  • Environmental evaluation
  • Map and directions services