country-info-package
v1.0.6
Published
A package for country information, including codes, names, flags, languages, and more.
Downloads
22
Maintainers
Readme
country-info-package
country-info-package
is an npm package designed to provide detailed information about countries. It includes data such as country codes, names, flags, languages, and more, simplifying the process of accessing country-related information for developers.
Installation
To install the country-info-package
npm package, use the following command:
npm install country-info-package
How To Use
import { getCountryInfo } from "country-info-package";
// Example usage
// By country code
const countryByCode = getCountryInfo("ZW");
console.log(countryByCode);
// By country title
const countryByTitle = getCountryInfo("Zimbabwe");
console.log(countryByTitle);
// By phone code
const countryByPhoneCode = getCountryInfo("+263");
console.log(countryByPhoneCode);
Example Output
The getCountryInfo
function returns an object with detailed country information:
{
"title": "Zimbabwe",
"code": "ZW",
"time_zone": "UTC+2",
"currency": {
"name": "Zimbabwean Dollar",
"symbol": "$"
},
"languages": ["English", "Shona", "Sindebele"],
"ISO_codes": {
"numeric": "716",
"alpha3": "ZWE"
},
"phone_code": "+263",
"area_km2": 390757,
"flag": "🇿🇲"
}
API
getCountryInfo(value)
Parameters:
value
(string): The country code (e.g., 'ZW'),
country title (e.g., 'Zimbabwe'), or
phone code (e.g., '+263').
Returns:
An object with country information, including the flag, or an object with a message if the country is not found.
Dependencies:
country-flag-icons
: Provides country flag icons.
License
This package is licensed under the ISC License.
Author
Rizwan Khan (Captain)