world-locations
v1.0.0
Published
A Node.js package to retrieve data about countries, states, and cities using JSON files.
Downloads
4
Maintainers
Readme
Country, State, and City Data
country-state-city-list is an NPM package that provides functions to retrieve data about countries, states, and cities using JSON files. It is a simple and convenient way to access this geographical information for use in your Node.js applications.
Installation
You can install this package using npm:
npm install country-state-city-data
Usage
const cscData = require('country-state-city-data');
// Get all countries
const allCountries = cscData.getAllCountries();
// Get states by countryId
const statesInCountry = cscData.getStatesByCountryId(countryId);
// Get cities by stateId
const citiesInState = cscData.getCitiesByStateId(stateId);
Functions:
getAllCountries() Returns an array of all countries.
getStatesByCountryId(countryId) Returns an array of states in a country specified by countryId.
getCitiesByStateId(stateId) Returns an array of cities in a state specified by stateId.