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

global-locations

v1.1.1

Published

A comprehensive package providing a list of all regions, subregions, countries, states, and cities.

Downloads

42

Readme

Global Locations

** global-locations ** is a comprehensive npm package that provides users with an extensive and structured list of all regions, subregions, countries, states, and cities around the world. This package is designed to be a one-stop solution for developers who need reliable geographical data for various applications, including web development, data analysis, and more.

Features

  • Comprehensive Data: Access a complete database of regions, subregions, countries, states, and cities worldwide.
  • Structured Format: Data is well-organized and easy to navigate, ensuring seamless integration into your projects.
  • Up-to-Date Information: Regularly updated to reflect the latest geographical changes and new entries.
  • TypeScript Support: Fully typed definitions for TypeScript users, providing a better development experience and reducing errors.
  • Easy to Use: Simple and intuitive API that makes fetching and utilizing geographical data straightforward.

Install

npm i global-locations

Usage

  • ES6 Module usage

    import { Region, SubRegion, Country, State, City } from "global-locations";
    import {
      IRegion,
      ISubRegion,
      ICountry,
      IState,
      ICity,
    } from "global-locations"; //for intervace
  • AMD Module usage

    let { Region, SubRegion, Country, State, City } = require("global-locations");

Docs

Region Request method

Here are all region related methods.

Region.getAllRegions()

Region.sortedRegions(field)

Here field can be id or name. and sort always will be ascending

Region.getFiltedRegions(field, value, sort)

Here field can be id or name. value will be the value you are looking for. and sort always will be ascending

Sub Region Request method

Here are all sub region related methods.

SubRegion.getAllSubRegions()

SubRegion.sortedSubRegions(field)

Here field can be id or name. and sort always will be ascending

SubRegion.getSubRegionOfRegion(field, value, sort)

Here field can be region or regionId. value will be the value you are looking for by region. and sort always will be ascending

SubRegion.getFiltedSubRegions(field, value, sort)

Here field can be id or name. value will be the value you are looking for. and sort always will be ascending

Country Request method

Here are all country related methods.

Country.getAllCountries()

Country.sortedCountries(field)

Here field can be id/name/iso3/iso2/numericCode any field of country. and sort always will be ascending

Country.getCountriesOfRegion(field, value, sort)

Here field can be region or regionId. value will be the value you are looking for by region. and sort always will be ascending

Country.getCountriesOfSubRegion(field, value, sort)

Here field can be subregion or subregionId. value will be the value you are looking for by sub region. and sort always will be ascending

Country.getFiltedCountries(field, value, sort)

Here field can be id or name. value will be the value you are looking for. and sort always will be ascending

State Request method

Here are all country related methods.

State.getAllStates()

State.sortedStates(field)

Here field can be id/name/stateCode of state. and sort always will be ascending

State.getStateOfCountry(field, value, sort)

Here field can be countryId or countryCode(two-letter code) or countryName. value will be the value you are looking for by state. and sort always will be ascending

State.getFiltedStates(field, value, sort)

Here field can be id or name or stateCode. value will be the value you are looking for. and sort always will be ascending

City Request method

Here are all city related methods.

City.getAllCities()

City.sortedCities(field)

Here field can be id/name of city. and sort always will be ascending

City.getCitiesOfCountry(field, value, sort)

Here field can be countryId or countryName, countryCode(two-letter code). value will be the value you are looking for by country. and sort always will be ascending

City.getCitiesOfState(field, value, sort)

Here field can be stateId or stateName, stateCode(three-letter code). value will be the value you are looking for by state. and sort always will be ascending

City.getFiltedCities(field, value, sort)

Here field can be id or name. value will be the value you are looking for. and sort always will be ascending

Example structure data

type: json | IRegion

[
  {
    "id": 1,
    "name": "Africa",
    "translations": {
      "kr": "아프리카",
      "pt-BR": "África",
      "pt": "África",
      "nl": "Afrika",
      "hr": "Afrika",
      "fa": "آفریقا",
      "de": "Afrika",
      "es": "África",
      "fr": "Afrique",
      "ja": "アフリカ",
      "it": "Africa",
      "cn": "非洲",
      "tr": "Afrika"
    }
  },
  ...
]

type: json | ISubRegion

[
  {
    "id": 19,
    "name": "Australia and New Zealand",
    "region": "Oceania",
    "regionId": 5,
    "translations": {
      "korean": "오스트랄라시아",
      "portuguese": "Australásia",
      "dutch": "Australazië",
      "croatian": "Australazija",
      "persian": "استرالزی",
      "german": "Australasien",
      "spanish": "Australasia",
      "french": "Australasie",
      "japanese": "オーストララシア",
      "italian": "Australasia",
      "chinese": "澳大拉西亞"
    }
  },
  ...
]

type: json | ICountry

[
  {
    "id": 1,
    "name": "Afghanistan",
    "iso3": "AFG",
    "iso2": "AF",
    "numericCode": "004",
    "phoneCode": "93",
    "capital": "Kabul",
    "currency": "AFN",
    "currencyName": "Afghan afghani",
    "currencySymbol": "؋",
    "tld": ".af",
    "native": "افغانستان",
    "region": "Asia",
    "regionId": 3,
    "subregion": "Southern Asia",
    "subregionId": 14,
    "nationality": "Afghan",
    "timezones": [
      {
        "zoneName": "Asia/Kabul",
        "gmtOffset": 16200,
        "gmtOffsetName": "UTC+04:30",
        "abbreviation": "AFT",
        "tzName": "Afghanistan Time"
      }
    ],
    "translations": {
      "kr": "아프가니스탄",
      "pt-BR": "Afeganistão",
      "pt": "Afeganistão",
      "nl": "Afghanistan",
      "hr": "Afganistan",
      "fa": "افغانستان",
      "de": "Afghanistan",
      "es": "Afganistán",
      "fr": "Afghanistan",
      "ja": "アフガニスタン",
      "it": "Afghanistan",
      "cn": "阿富汗",
      "tr": "Afganistan"
    },
    "latitude": "33.00000000",
    "longitude": "65.00000000",
    "emoji": "🇦🇫",
    "emojiU": "U+1F1E6 U+1F1EB"
  },
  ...
]

type: json | IState

[
  {
    "id": 3901,
    "name": "Badakhshan",
    "countryId": 1,
    "countryCode": "AF",
    "countryName": "Afghanistan",
    "stateCode": "BDS",
    "type": null,
    "latitude": "36.73477250",
    "longitude": "70.81199530"
  },
  ...
]

type: json | ICity

[
  {
    "id": 52,
    "name": "Ashkāsham",
    "stateId": 3901,
    "stateCode": "BDS",
    "stateName": "Badakhshan",
    "countryId": 1,
    "countryCode": "AF",
    "countryName": "Afghanistan",
    "latitude": "36.68333000",
    "longitude": "71.53333000"
  },
  ...
]

Advertise for Job/Work Contract

I am open for a good job or work contract. You can contact me directly on my email ([email protected]) or on my skype ujjwalbera.

Buy me a Coffee

Hi! I'm Ujjwal Bera, I'm an open source enthusiast and devote my free time to building projects in this field.

I'm the creator and maintainer of MNodeJs and SNodeJs.

I'm doing my best to provide you a good experience when using my apps, so if you like what I'm doing and wish to say "thanks!", You can appreciate me or my hard work and time spent to create this helpful structure with buying me a coffee.

Bugs or improvements

Every project needs improvements, Feel free to report any bugs or improvements. Improvements requests are always welcome.

Who do I talk to?

License

This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.

Acknowledgments

Thanks to the open-source community for inspiring and contributing to the tools used in this project.