
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
countries-data-kit
Advanced tools
Country data with advanced filters: ISO codes, capitals, continents, currencies, dialing codes, flags, emergency numbers, and phone masking. Tiny package, compatible with backend and frontend JS frameworks
countries-data-kit is a powerful, minimal-sized JavaScript package offering over 15 types of detailed country information with advanced filtering options. It adhers to ISO 3166 for countries, ISO 4217 for currencies, and ISO 639 for languages.
🔧 Wide Compatibility: Runs seamlessly in Node.js, React, React Native, and browser environments.
📚 Comprehensive Data: Fetch Currency Details, Get Dialing Codes, Display Flag Emojis, Provide Language Info, Access Emergency Numbers, Driving Side Info, Get Phone Number Masks
📏 ISO Standards Compliance: Adheres to ISO 3166 for countries, ISO 4217 for currencies, and ISO 639 for languages.
🔍 Flexible Filtering: Filter data by over 10 different criteria to get precisely the information you need.
You can install the package via npm or yarn:
npm install countries-data-kit
or
yarn add countries-data-kit
The main function, getCountries({ fields:[], filters:{}|[] }), retrieves country details based on two parameters:
fields: Specify which country data you want, such as mobile number mask, capital, or dialing code. Use the CFields enum or pass a string array.
filters: Define criteria to filter countries, like continent, alpha-2/alpha-3 code, name, or dialing number.
This setup gives you control over the data you receive and how countries are selected.
const { getCountries, SFields, CFields } = require('countries-data-kit');
import { getCountries, CFields, SFields } from 'countries-data-kit';
for filters it could be passed as object or array both syntaxes are correct and the details of how to pass them are shown below
To get data for all 249 countries, simply call the getCountries function:
const countries = getCountries();
or
const countries = getCountries({});
If you only need certain fields, such as phone number details, you can specify them using the fields parameter:
const countriesPhoneNumberDetails = getCountries({
fields: [
CFields.dialingCode,
CFields.phoneNumberMask
]
});
Alternatively, you can pass them as strings:
const countriesPhoneNumberDetails = getCountries({
fields: [
"dialingCode",
"phoneNumberMask"
]
});
To filter countries by certain criteria, such as continent or country code, use the filters parameter.
Get all Asian and European countries:
const asianCountries = getCountries({
filters: [
SFields.continentNames.Asia
]
});
or
const asianCountries = getCountries({
filters: {
continentName:"Asia"
}
});
or
const asianCountries = getCountries({
filters: {
continentName:["Asia"]
}
});
You can also filter by specific country codes:
let countries = getCountries({
filters: {
alpha2Code: ["US", "CA", "EG", "JP"]
}
});
You can combine fields and filters to retrieve specific data. For example, to get the capital city of Germany:
let countries = getCountries({
fields: [CFields.capitalCity],
filters: [SFields.countryNames.Germany]
});
or
let countries = getCountries({
fields: [
CFields.capitalCity
],
filters: {
countryName: "Germany"
}
});
Retrieve in which continents specific countries exist based on their alpha3 codes:
let countries = getCountries({
fields: [
CFields.continentName
],
filters: {
alpha3Code: ["DZA", "AUT"]
}
});
You can apply multiple filters to retrieve data that meets several criteria. For example, to get all countries with Cairo as the capital, a specific flag, and those that use the Euro:
let countries = getCountries({
fields: [CFields.continentName],
filters: [
SFields.capitalCities.Cairo,
SFields.flagEmojis["🇺🇸"],
SFields.currencyCodes.EUR
]
});
or
let countries = getCountries({
fields:[CFields.continentName],
filters:{
capitalCity:"Cairo",
flagEmoji:"🇺🇸",
currencyCode:"EUR"
}
})
the above call will return all countries that use Euro + Egypt + USA
Retrieve the dialing codes and flag emojis for all countries:
const countries = getCountries({
fields: [CFields.dialingCode, CFields.flagEmoji]
});
Retrieve the dialing code and phone mask for a specific country or multiple countries:
const countryDetails = getCountries({
fields: [CFields.dialingCode, CFields.phoneNumberMask],
filters: [
SFields.countryNames['United Arab Emirates'],
SFields.countryNames['United States of America']
]
});
Retrieve the emergency numbers for the United States:
const emergencyNumbersUS = getCountries({
fields: [CFields.emergencyNumbers],
filters: {
alpha2Code: "US"
//alpha3Code: "USA"
//countryName: "United States of America"
//capitalCity:"Washington, D.C."
}
});
Find out the driving side in France:
const drivingSideFrance = getCountries({
fields: [CFields.drivingSide],
filters: {
countryName: "France"
}
});
or
const drivingSideFrance = getCountries({
fields: [CFields.drivingSide],
filters: [SFields.countryNames.France]
});
Retrieve the names of all countries that use USD as their currency:
const usdCountries = getCountries({
fields: [CFields.countryName],
filters: [SFields.currencyCodes.USD]
});
or
const usdCountries = getCountries({
fields: [CFields.countryName],
filters: {
currencyCode: "USD"
}
});
The package provides the following data fields: CFields
| Field | Description | Example | How to Access |
|---|---|---|---|
alpha2Code | ISO 3166-1 alpha-2 code | "US" | CFields.alpha2Code |
alpha3Code | ISO 3166-1 alpha-3 code | "USA" | CFields.alpha3Code |
capitalCity | Capital city | "Washington, D.C." | CFields.capitalCity |
continentName | Continent name | "North America" | CFields.continentName |
countryName | Official country name | "United States of America" | CFields.countryName |
currency | Official currency name | "United States dollar" | CFields.currency |
currencyCode | ISO 4217 currency code | "USD" | CFields.currencyCode |
currencySymbol | Currency symbol | "$" | CFields.currencySymbol |
dialingCode | International dialing code | "+1" | CFields.dialingCode |
drivingSide | Driving side ("left" or "right") | "right" | CFields.drivingSide |
emergencyNumbers | List of emergency numbers | {"police": "911", "fire": "911", "ambulance": "911"} | CFields.emergencyNumbers |
flagEmoji | Flag emoji | "🇺🇸" | CFields.flagEmoji |
flagSVGUrl | URL to SVG image of the flag | "https://example.com/flag.svg" | CFields.flagSVGUrl |
numericCountryCode | Numeric country code | "840" | CFields.numericCountryCode |
phoneNumberMask | Phone number format mask | "+1 (###) ###-####" | CFields.phoneNumberMask |
primaryLanguage | Primary language | "English" | CFields.primaryLanguage |
SFields Values:This method allows you to filter countries by providing an array of values from the SFields mappings.
Example:
const filteredCountries = getCountries({
filters: [SFields.alpha2Codes.US, SFields.continentNames.Africa]
});
SFields Table:
| Field | How to Access |
|---|---|
alpha2Codes | SFields.alpha2Codes |
alpha3Codes | SFields.alpha3Codes |
capitalCities | SFields.capitalCities |
continentNames | SFields.continentNames |
countryNames | SFields.countryNames |
currencies | SFields.currencies |
currencyCodes | SFields.currencyCodes |
dialingCodes | SFields.dialingCodes |
drivingSides | SFields.drivingSides |
flagEmojis | SFields.flagEmojis |
numericCountryCodes | SFields.numericCountryCodes |
phoneNumberMasks | SFields.phoneNumberMasks |
primaryLanguages | SFields.primaryLanguages |
This method provides more control by allowing you to specify filters as key-value pairs, where the keys correspond to the filter object keys and the values are the criteria you want to filter by.
Example:
const filteredCountries = getCountries({
filters: {
continentName: ["Europe", "Asia"],
alpha2Code: "EG"
}
});
Filter Object Key Table:
| Filter Object Key | Example |
|---|---|
alpha2Code | "EG" |
alpha3Code | "USA" |
capitalCity | "Cairo" |
continentName | ["Europe", "Asia"] |
countryName | "United States of America" |
currency | "Egyptian pound" |
currencyCode | "USD" |
dialingCode | ["+20", "+1"] |
drivingSide | "right" |
flagEmoji | "🇪🇬" |
numericCountryCode | "840" |
phoneNumberMask | "(###) ###-####" |
primaryLanguage | ["English", "Arabic"] |
Contributions are welcome! Please check the contribution guidelines for more details.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or support, please open an issue on GitHub or contact us via email at mm7modmgdy@gmail.com.
Happy coding! 🎉
FAQs
Country data with advanced filters: ISO codes, capitals, continents, currencies, dialing codes, flags, emergency numbers, and phone masking. Tiny package, compatible with backend and frontend JS frameworks
We found that countries-data-kit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.