Installations
npm install node-countries
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.17.0
NPM Version
10.8.2
Score
84
Supply Chain
100
Quality
77.1
Maintenance
100
Vulnerability
99.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.15%)
JavaScript (0.85%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
marchah
Download Statistics
Total Downloads
691,456
Last Day
798
Last Week
3,166
Last Month
13,628
Last Year
199,776
GitHub Statistics
11 Stars
153 Commits
13 Forks
2 Watching
5 Branches
6 Contributors
Bundle Size
180.58 kB
Minified
49.69 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.4.0
Package Id
node-countries@2.4.0
Unpacked Size
523.58 kB
Size
59.88 kB
File Count
13
NPM Version
10.8.2
Node Version
20.17.0
Publised On
03 Oct 2024
Total Downloads
Cumulative downloads
Total Downloads
691,456
Last day
13.7%
798
Compared to previous day
Last week
-12.8%
3,166
Compared to previous week
Last month
8.6%
13,628
Compared to previous month
Last year
13.8%
199,776
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
21
node-countries
Countries JSON data
Installation
Install via npm:
$ npm install node-countries
Documentation
This module currently has states and provinces for:
- United States (US)
- United Kingdom (GB)
- Canada (CA)
- Mexico (MX)
- Australia (AU)
- China (CN)
- Germany (DE)
- Belgium (BE)
- Netherlands (NL)
- Denmark (DK)
- Turkey (TR)
- Indonesia (ID)
- Jordan (JO)
- India (IN)
- Cambodia (KH)
- Ethiopia (ET)
- Peru (PE)
- Cuba (CU)
- Argentina (AR)
- Chile (CL)
- Bolivia (BO)
- Spain (ES)
- Bangladesh (BD)
- Pakistan (PK)
- Nigeria (NG)
- Japan (JP)
- Austria (AT)
- Brazil (BR)
- Philippines (PH)
- Vietnam (VN)
- Bulgaria (BG)
Data
getCountries()
1import { getCountries } from 'node-countries'
Return a JSON array with all the countries
1[ 2 { 3 "alpha2": "AC", 4 "alpha3": "", 5 "countryCallingCodes": [ 6 "+247" 7 ], 8 "currencies": [ 9 "USD" 10 ], 11 "ioc": "SHP", 12 "languages": [ 13 "eng" 14 ], 15 "name": "Ascension Island", 16 "status": "reserved", 17 "provinces": null, 18 "alias": null 19 }, 20 { 21 "alpha2": "AD", 22 "alpha3": "AND", 23 "countryCallingCodes": [ 24 "+376" 25 ], 26 "currencies": [ 27 "EUR" 28 ], 29 "ioc": "AND", 30 "languages": [ 31 "cat" 32 ], 33 "name": "Andorra", 34 "status": "assigned", 35 "provinces": null, 36 "alias": null 37 }, 38 ... 39]
Short cut
All the countries are accessible directly through their ISO 639-1 (two letter code)
1import countries from 'node-countries'; 2 3console.log(countries.AC); 4/* 5 { 6 "alpha2": "AC", 7 "alpha3": "", 8 "countryCallingCodes": [ 9 "+247" 10 ], 11 "currencies": [ 12 "USD" 13 ], 14 "ioc": "SHP", 15 "languages": [ 16 "eng" 17 ], 18 "name": "Ascension Island", 19 "status": "reserved", 20 "provinces": null, 21 "alias": null 22 } 23*/
Methods
getCountryByName(name, [useAlias])
1import { getCountryByName } from 'node-countries'
Return the matched country object, else null (alias: findCountryByName
)
getCountryByNameOrShortName(name or short name (alpha2, alpha3), [useAlias])
1import { getCountryByNameOrShortName } from 'node-countries'
Return the matched country object, else null (alias: findCountryByNameOrShortName
)
getProvinceByName(country, provinceName, [useAlias])
Return the matched province object, else null (alias: findProvinceByName
)
getProvinceByNameOrShortName(country, provinceName or short name, [useAlias])
Return the matched province object, else null (alias: findProvinceByNameOrShortName
)
Examples
1import { getCountryByName } from 'node-countries' 2 3console.log(getCountryByName("Andorra")); 4/* 5 { 6 "alpha2": "AD", 7 "alpha3": "AND", 8 "countryCallingCodes": [ 9 "+376" 10 ], 11 "currencies": [ 12 "EUR" 13 ], 14 "ioc": "AND", 15 "languages": [ 16 "cat" 17 ], 18 "name": "Andorra", 19 "status": "assigned", 20 "provinces": null, 21 "alias": null 22 } 23*/
1import countries from "node-countries"; 2 3console.log(getProvinceByName(countries.CA, "Labrador", false)); 4/* 5 null 6*/ 7 8console.log(getProvinceByName(countries.CA, "Labrador", true)); 9/* 10 { 11 "short": "NL", 12 "name": "Newfoundland and Labrador", 13 "alias": [ 14 "Newfoundland", 15 "Labrador" 16 ] 17 } 18*/
Note
Inspired by country-data and provinces
Contributing
This project is a work in progress and subject to API changes, please feel free to contribute
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
8 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Reason
Found 1/6 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 27 are checked with a SAST tool
Score
2.1
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to node-countries
countries-list
Continents & countries: ISO 3166-1 alpha-2 code, name, ISO 639-1 languages, capital, currency, native name, phone. JSON, CSV and SQL.
rest-countries-node
A Node.js wrapper library around the API provided by http://restcountries.eu
vtio-node-countries
node-countries-list
List of all countries with names and ISO 3166-1 codes in all languages.