Gathering detailed insights and metrics for countrily
Gathering detailed insights and metrics for countrily
Gathering detailed insights and metrics for countrily
Gathering detailed insights and metrics for countrily
npm install countrily
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
43 Commits
1 Watchers
9 Branches
1 Contributors
Updated on Mar 03, 2021
Latest Version
1.5.2
Package Id
countrily@1.5.2
Unpacked Size
14.16 kB
Size
5.03 kB
File Count
8
NPM Version
6.14.11
Node Version
14.15.5
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
5
Inspired by the work of the authors of countryjs, this is a Node.js module for returning data about countries but can also be run in the browser unlike the original project. Use this to get a list of countries (country list) and their corresponding meta data
1npm install countrily
To access one of the country properties available, you'll need to use one of the API methods listed below and pass a country in either way:
var country = new Country('NG', 'ISO2')
or var country = new Country('NG')
(defaults)var country = new Country('NG', 'ISO3')
country.states()
..info()
Returns all available information for a specified country.
1var Countrily = require('countrily'); 2var nigeria = new Countrily('NGA', 'ISO3'); // 'ISO2', 'ISO3', 'name' 3var nigeria = new Countrily('NG'); // Defaults to ISO2 4nigeria.info(); 5// returns object, 6// { 7// "name": "Nigeria", 8// "altSpellings": ["NG", "NGA", "Federal Republic of Nigeria"], 9// "area": 923768, 10// "borders": ["BEN","CMR","TCD","NER"], 11// "callingCodes": ["234"], 12// "capital": "Abuja", 13// "currencies": ["NGN"], 14// "demonym": "Nigerian", 15// ... 16// }
.states()
Returns all states/provinces for a specified country.
1var Countrily = require('countrily'); 2var nigeria = Countrily('NG', 'ISO2'); // 'ISO2', 'ISO3', 'name'. 3var nigeria = Countrily('NG') 4nigeria.states(); 5// returns array of states, 6// [ 7// "Adamawa", 8// ... 9// ]
.provinces()
Alias of .states()
.name()
Returns name for a specified country
1var Countrily = require('countrily'); 2var nigeria = Countrily('NGA', 'ISO3'); // 'ISO2', 'ISO3', 'name' 3var nigeria = Countrily('NG'); // Defaults to 'ISO2' 4country.name() // Defaults to 'ISO2' 5// returns string 6// "Nigeria"
.altSpellings()
Returns alternate spellings for the name of a specified country
1nigeria.altSpellings() 2// returns array of strings, alternate names 3// ["NG","Nijeriya","Naíjíríà","Federal Republic of Nigeria"]
.area()
Returns area (km²) for a specified country
1nigeria.area() 2// returns number of square kilometer area 3// 923768
.borders()
Returns bordering countries (ISO3) for a specified country
1nigeria.borders() // Defaults to 'ISO2' 2// returns array of strings, ISO3 codes of countries that border the given country 3// ["BEN","CMR","TCD","NER"]
.callingCodes()
Returns international calling codes for a specified country
1nigeria.callingCodes() // Defaults to 'ISO2' 2// returns array of calling code strings 3// ["234"]
.capital()
Returns capital city for a specified country
1nigeria.capital() 2// returns string 3// "Abuja"
.currencies()
Returns official currencies for a specified country
1nigeria.currencies() 2// returns array of strings, currencies 3// ["NGN"]
.demonym()
Returns the demonyms for a specified country
1nigeria.demonym() 2// returns string, name of residents 3// "Nigerian"
.flag() - INCOMPLETE
Returns SVG link of the official flag for a specified country
1nigeria.flag() 2// returns string URL of CC licensed svg flag
.geoJSON()
Returns geoJSON for a specified country
1nigeria.geoJSON() 2// returns object of GeoJSON data
.ISOcodes()
Returns ISO codes for a specified country
1nigeria.ISOcodes() 2// returns object of ISO codes 3// { 4// "alpha2": "NG", 5// "alpha3": "NGA" 6// }
.languages()
Returns official languages for a specified country
1nigeria.languages() 2// returns array of language codes 3// ["en"]
.latlng()
Returns approx latitude and longitude for a specified country
1nigeia.latlng(); 2// returns array, approx latitude and longitude for country 3// [10,8]
.nativeName()
Returns the name of the country in its native tongue
1nigeria.nativeName(); 2// returns string, name of country in native language 3// "Nigeria"
.population()
Returns approximate population for a specified country
1nigeria.population(); 2// returns number, approx population 3// 178517000
.region()
Returns general region for a specified country
1nigeria.region(); 2// returns string 3// "Africa"
.subregion()
Returns a more specific region for a specified country
1nigeria.subregion(); 2// returns string 3// "West Africa"
.timezones()
Returns all timezones for a specified country
1nigeria.timezones(); 2// returns array of timezones
.tld()
Returns official top level domains for a specified country
1nigeria.tld(); 2// returns array of top level domains specific to the country 3// [".ng"]
.translations()
Returns translations for a specified country name in popular languages
1nigeria.translations(); 2// returns object of translations of country name in major languages 3// { 4// "de": "Nigeria", 5// "es": "Nigeria", 6// "fr": "Nigeria", 7// "ja": "ナイジェリア", 8// "it": "Nigeria" 9// }
.wiki()
Returns link to wikipedia page for a specified country
1nigeria.wiki(); 2// returns string URL of wikipedia article on country 3// "http://en.wikipedia.org/wiki/Nigeria"
Two static methods are exposed to return all data and shortnames
.all()
Return all country data. This will be super big. Not recommended.
1var Countrily = require('countrily'); 2Countrily.all(); 3// returns array of objects, 4// [{ 5// "name": "Nigeria", 6// "altSpellings": ["NG", "NGA", "Federal Republic of Nigeria"], 7// "area": 923768, 8// "borders": ["BEN","CMR","TCD","NER"], 9// "callingCodes": ["234"], 10// "capital": "Abuja", 11// "currencies": ["NGN"], 12// "demonym": "Nigerian", 13// ... 14// }, 15// ...]
.shortnamesofall()
Return an array of all the shortnames (ISO2) of all the countries.
1var Countrily = require('countrily'); 2Countrily.shortnamesofall();
.lean(field)
Return an array of field entered.
1const Countrily = require('countrily'); 2Countrily.lean('name'); 3 4['Afghanistan', 5 'Albania', 6 'Algeria', 7 'American Samoa', 8 'Angola', 9 'Anguilla', 10 'Antigua and Barbuda', 11 'Argentina', 12 'Armenia', 13 'Aruba', 14 ...]
test/
folder, and run:1npm test
This is being maintained in the contributor's free time, and as such, may contain minor errors in regards to some countries. Most of the information included in this library is what is listed on Wikipedia. If there is an error, please let me know and I will do my best to correct it.
Copyright (c) 2017, Timi Aiyemo cozzbie@gmail.com
Please see licence file.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
18 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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 More