The 'iran-city' package can be installed using npm with the following command:
npm install iran-city
Here are some examples of how to use the package:
-
Get all cities in Iran:
let iranCity = require('iran-city'); let AllCities = iranCity.allCities(); console.log(AllCities);
-
Get all provinces in Iran:
let iranCity = require('iran-city'); let AllProvinces = iranCity.allProvinces(); console.log(AllProvinces);
-
Get cities of a specific province (e.g., province ID 20):
let iranCity = require('iran-city'); let CitiesOfProvince = iranCity.citiesOfProvince(20); console.log(CitiesOfProvince);
-
Search for cities by name (e.g., search for "کرمان"):
let iranCity = require('iran-city'); let SearchByName = iranCity.searchByName('کرمان'); console.log(SearchByName);
-
Get city information by name (e.g., get information about "رفسنجان"):
let iranCity = require('iran-city'); let CityByName = iranCity.cityByName('رفسنجان'); console.log(CityByName);
-
Get city information by ID (e.g., get information about city ID 766):
let iranCity = require('iran-city'); let CityById = iranCity.cityById(766); console.log(CityById);
-
Get city information by slug (e.g., get information about city slug 'رفسنجان'):
let iranCity = require('iran-city'); let CityBySlug = iranCity.CityBySlug('رفسنجان'); console.log(CityBySlug);
-
Search for cities by slug (e.g., search for "کرمان"):
let iranCity = require('iran-city'); let PCitiesBySlug = iranCity.PCitiesBySlug('کرمان'); console.log(PCitiesBySlug);
Sources:
npmjs link: iran-city - npm
-
Thanks to @sajaddp for the help
-
made with ❤ by Mohammad Hassani