
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
country-data-api
Advanced tools
A simple API that provides country, state, and city data. You can retrieve information about countries, their states, cities, and related details using this library.
To install the package, run the following command:
npm install country-data-api
Get All Countries
This method returns a list of all countries.
import { getAllCountries } from 'country-data-api';
const countries = getAllCountries();
console.log(countries);
=========================================================
Get All Country Names
This method returns an array of country names.
import { getAllCountryNames } from 'country-data-api';
const countryNames = getAllCountryNames();
console.log(countryNames);
=========================================================
Get Country Details by Country Name
This method returns the details of a country based on its name. If the country is found, it returns the details; otherwise, it returns undefined.
import { getCountryDetailsByName } from 'country-data-api';
const countryDetails = getCountryDetailsByName('Bangladesh');
console.log(countryDetails);
=========================================================
Get Cities by State Names
This method allows you to get the list of cities by state names. You can pass a single state name or an array of state names.
import { getCitiesByStateNames } from 'country-data-api';
// Get cities by a single state name
const citiesInState = getCitiesByStateNames('Dhaka');
console.log(citiesInState);
// Get cities by an array of state names
const citiesInStates = getCitiesByStateNames(['Dhaka', 'Chittagong']);
console.log(citiesInStates);
=========================================================
Get States by Country Name
import { getStatesByCountryName } from 'country-data-api';
const statesInCountry = getStatesByCountryName('Bangladesh');
console.log(statesInCountry);
FAQs
Get all country, state, and city data
The npm package country-data-api receives a total of 7 weekly downloads. As such, country-data-api popularity was classified as not popular.
We found that country-data-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.