Country related data such as ISO codes, currencies etc
Installations
npm install country-data
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
4.2.1
NPM Version
2.14.7
Score
99.1
Supply Chain
99.6
Quality
79.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (97.59%)
Makefile (2.41%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
OpenBookPrices
Download Statistics
Total Downloads
21,293,715
Last Day
15,825
Last Week
62,323
Last Month
275,369
Last Year
4,246,967
GitHub Statistics
517 Stars
204 Commits
165 Forks
13 Watching
3 Branches
19 Contributors
Bundle Size
135.44 kB
Minified
28.80 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.0.31
Package Id
country-data@0.0.31
Size
45.59 kB
NPM Version
2.14.7
Node Version
4.2.1
Publised On
25 Oct 2016
Total Downloads
Cumulative downloads
Total Downloads
21,293,715
Last day
12.1%
15,825
Compared to previous day
Last week
-10.6%
62,323
Compared to previous week
Last month
3.4%
275,369
Compared to previous month
Last year
-3.4%
4,246,967
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
4
Country Data
There are lots of little bits of data that you often need relating to countries, and I couldn't find any easy to use source of it. So I compiled it all here.
Work in Progress
This code base may change a bit until it hits 0.1.x
- feel free to use it, but be sure to check between upgrades.
I suspect that many of the currencies
entries on the countries may be wrong. Help checking them would be appreciated.
Countries
The data currently provided for each country is:
name
The english name for the countryalpha2
The ISO 3166-1 alpha 2 codealpha3
The ISO 3166-1 alpha 3 codestatus
: The ISO status of the entry - see below.currencies
An array of ISO 4217 currency codes with the primary one firstlanguages
An array of ISO 639-2 codes for languages (may not be complete).countryCallingCodes
An array of the international call prefixes for this country.ioc
The International Olympic Committee country codeemoji
The emoji of country's flag.
Status notes
The status
can be one of 'assigned', 'reserved', 'user assigned' or 'deleted'.
Assigned means that the code is properly in the ISO 3166 standard. Reserved means that the code is being prevented from being used. Deleted means that it has been deleted. User Assigned means that for some use cases it is required. Deleted means that it used to be in the standard but is now not.
See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for full details, especially the "User-assigned code elements" and "Reserved code elements" sections.
Regions
Countries are ofter grouped into regions. The list of regions is by no means exhaustive, pull requests very welcome for additions.
countries
An array ofalpha2
codes for the countries in this region.
Currencies
It is not that useful to just have the currency code(s) for a country, so included is currency data too:
name
The english name for the currencycode
The ISO 4217 codenumber
The ISO 4217 numberdecimals
The number of decimal digits conventionally shownsymbol
The currency symbol for the currency (e.g. ¥, $ etc.). Some symbols are not available, in which casesymbol
contains the ISO 4217 code. Credit to bengourley/currency-symbol-map for the symbol database.
Languages
A list of languages provided by ISO 639-2;
name
The english name for the languagealpha2
The two letter ISO 639-1 code for the language (may be blank).alpha3
The three letter terminological ISO 639-2 code for the language (may be blank).bibliograpic
The three letter bibliographic ISO 639-2 code for the language (may be blank).
Lookup
To make finding easier there are utility methods that can search the countries and currencies. See examples below.
Installing
1npm install country-data
Example usage
1var countries = require('country-data').countries, 2 currencies = require('country-data').currencies, 3 regions = require('country-data').regions, 4 languages = require('country-data').languages, 5 callingCountries = require('country-data').callingCountries; 6 7// .all gives you an array of all entries 8console.log( countries.all ); 9console.log( currencies.all ); 10 11// countries are found using alpha2 or alpha3 (both uppercase) 12console.log( countries.BE.name ); // 'Belgium' 13console.log( countries.FRA.currencies ); // ['EUR'] 14 15// callingCountries is like countries but only has entries with dialing codes. 16 17// currencies are accessed by their code (uppercase) 18console.log( currencies.USD.name ); // 'United States dollar' 19 20// regions are accessed using a camel case name 21console.log( regions.europe.countries )
1var lookup = require('country-data').lookup; 2 3// Match a value (grab first from array) 4var france = lookup.countries({name: 'France'})[0]; 5 6// Or match one of several possible values. 7var eurozone_countries = lookup.countries({currencies: 'EUR'});
It is very simple for now - feel free to contribute more helpful accessors.
Possible future additions
More data for each country is most welcome. Obvious things that it might be nice to add are:
Countries
- Wikipedia links
- Coordinates (centroid, bounding box, etc)
Currencies
- other currency that it is pegged to
Using with webpack
As this code loads the data from JSON files you need to add the JSON loader to webpack:
1npm install json-loader --save-dev
and then include in your webpack.config.js
:
1// ... 2 loaders: [ 3 // other loaders 4 { test: /\.json$/, loader: 'json' }, 5 ], 6// ...
Other similar bits of code
- libphonenumber "Google's common Java, C++ and Javascript library for parsing, formatting, storing and validating international phone numbers."
How to contribute
The final format is JSON, but it is easier to work with CSV. Hence in the data
folder there are CSV files and scripts that convert them to JSON. Please don't
edit the JSON directly, but do it via the CSV.
These are the steps required:
1# Clone the repo (or better your fork of it) 2git clone https://github.com/OpenBookPrices/country-data.git 3cd country-data 4 5# install the dependencies 6npm install . 7 8# Edit the countries.csv 9open data/countries.csv 10 11# Convert the raw data (CSV or JS files) to JSON 12make 13 14# Run the tests 15mocha 16 17# If all is ok commit and push 18git add . 19git commit 20git push 21 22# Then send a pull request with your changes. Ideally use several small commits, 23# and reference a source that backs up the change.
Sources
The currency data was copied from the Wikipedia ISO 4217 page.
The country calling codes came from the Wikipedia country calling codes page.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE.txt:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0
Reason
Found 4/24 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 10 are checked with a SAST tool
Score
3.2
/10
Last Scanned on 2025-02-03
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 country-data
country-telephone-data
Contains data about a country's telephone codes. It has information on the country's ISD code, the country's ISO name, and a subscribed format for the telephone numbers in that country.
@velocitycareerlabs/country-data
Contains ISO 3166-1 and ISO 3166-2 data
country-region-data
List of countries, regions, and their shortcodes.
@types/country-data
TypeScript definitions for country-data