1.2.0 • Published 12 months ago

@mr-mkz/atlas v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

AtlasJs library by Mr.MKZ

Atlas is a library that gives you region, subregion, country, state and city names with some special information if you want.

NPM Downloads

Report Bugs | Home Page

Installation

Install AtlasJs libary with npm

  npm install @mr-mkz/atlas

API Reference

Get all regions

  getAllRegions()

This function returns an object that contains list of all regions.

Get subregions

  getSubRegions()
ParameterTypeDescription
regionstringRequired. name of region to get subregions

This function return subregions of a region.

Get all countries

  getAllCountries()
ParameterTypeDescription
currencybooleando you want currency of country?
dialCodebooleando you want dial code of country?
nativebooleando you want native of country?
nationalitybooleando you want nationality of country?
regionbooleando you want region of country?
subregionbooleando you want subregion of country?
translationsbooleando you want translations of country?
timezonesbooleando you want timezones of country?
geolocationbooleando you want geolocation of country?
emojiesbooleando you want emojies of country?
domainbooleando you want domain of country?

This function gives you list of countries with some special information.

Get states of a country

  getCountryStates()
ParameterTypeDescription
countrystringRequired. country name
iso3stringRequired. country iso3
iso2stringRequired. country iso2
geolocationbooleando you want geolocation of each country state?

Tip: country name, iso3 or iso2, at least one of them is required!

This function gives you states of a country.

Get cities of a state

  getStateCities()
ParameterTypeDescription
countrystringRequired. country name
statestringRequired. state name to get cities
geolocationbooleando you want geolocation of each country state?

This function gives you cities of a state.

Usage/Examples

import {
  getAllCountries,
  getAllRegions,
  getSubRegions,
  getCountryStates,
  getStateCities
} from "@mr-mkz/atlas";

// Returns list of all regions.
getAllRegions().then((regions) => {
  console.log(regions);
}).catch((error) => {
  console.log(error);
})

// Returns list of subregions for Asia region.
getSubRegions("Asia").then((subregions) => {
  console.log(subregions);
}).catch((error) => {
  console.log(error);
})

// Returns list of all countries.
getAllCountries().then((countries) => {
  console.log(countries);
}).catch((error) => {
  console.log(error);
})

// Returns list of states for Iran.
getCountryStates("iran", "", "", true).then((states) => {
  console.log(states);
}).catch((error) => {
  console.log(error);
})

getCountryStates("", "IRN", "", true).then((states) => {
  console.log(states);
}).catch((error) => {
  console.log(error);
})

getCountryStates("", "", "IR", true).then((states) => {
  console.log(states);
}).catch((error) => {
  console.log(error);
})

// Returns list of cities for Razavi Khorasan state of Iran.
getStateCities("iran", "razavi khorasan", true).then((cities) => {
  console.log(cities);
}).catch((error) => {
  console.log(error);
})

Authors

1.2.0

12 months ago

1.1.0

1 year ago

1.0.0

1 year ago