Socket
Book a DemoInstallSign in
Socket

country-info-package

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

country-info-package

A package for country information, including codes, names, flags, languages, and more.

latest
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

country-info-package

npm version npm downloads

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)

Keywords

country

FAQs

Package last updated on 09 Aug 2024

Did you know?

Socket

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.

Install

Related posts