Installations
npm install country-query
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.19.1
NPM Version
6.14.16
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
petert82
Download Statistics
Total Downloads
243,388
Last Day
75
Last Week
783
Last Month
7,419
Last Year
150,576
GitHub Statistics
10 Stars
53 Commits
3 Forks
2 Watching
3 Branches
3 Contributors
Package Meta Information
Latest Version
2.0.3
Package Id
country-query@2.0.3
Unpacked Size
30.54 kB
Size
7.23 kB
File Count
10
NPM Version
6.14.16
Node Version
14.19.1
Total Downloads
Cumulative downloads
Total Downloads
243,388
Last day
-82.2%
75
Compared to previous day
Last week
-78.2%
783
Compared to previous week
Last month
17.7%
7,419
Compared to previous month
Last year
343.4%
150,576
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
5
country-query
A javascript query API for world-countries data.
Table of contents
API
find(by, value)
Finds data for one or more countries matching some search value.
Takes a property name to search by and a value to search for. If the value matches a single country, an object containing that country's data will be returned. If the value matches more than one country, an array of country objects will be returned. If no countries match, or an invalid property name is used, returns null
.
This function is not case-sensitive, i.e the input values German
, german
and gErMaN
would all match the language German
.
1var CountryQuery = require('country-query') 2 3var austria = CountryQuery.find('cca2', 'AT') 4var germany = CountryQuery.find('demonym', 'German') 5 6// austria and germany will both be objects with this structure: 7/* 8 { 9 "name": { 10 "common": "Austria", 11 "official": "Republic of Austria", 12 "native": { 13 "bar": { 14 "official": "Republik Österreich", 15 "common": "Österreich" 16 } 17 } 18 }, 19 "tld": [".at"], 20 "cca2": "AT", 21 "ccn3": "040", 22 "cca3": "AUT", 23 "cioc": "AUT", 24 "independent": true, 25 "status": "officially-assigned", 26 "currencies": { 27 "EUR": { "name": "Euro", "symbol": "\u20ac" } 28 }, 29 "idd": { 30 "root": "+4", 31 "suffixes": ["3"] 32 }, 33 "capital": ["Vienna"], 34 "altSpellings": ["AT", "Osterreich", "Oesterreich"], 35 "region": "Europe", 36 "subregion": "Western Europe", 37 "languages": { 38 "bar": "Austro-Bavarian German" 39 }, 40 "translations": { 41 "ces": { 42 "official": "Rakouská republika", 43 "common": "Rakousko" 44 }, 45 "cym": { 46 "official": "Gweriniaeth Awstria", 47 "common": "Awstria" 48 }, 49 "deu": { 50 "official": "Republik Österreich", 51 "common": "Österreich" 52 }, 53 // ...snip... 54 }, 55 "latlng": [47.33333333, 13.33333333], 56 "landlocked": true, 57 "borders": ["CZE", "DEU", "HUN", "ITA", "LIE", "SVK", "SVN", "CHE"], 58 "area": 83871, 59 "flag": "\ud83c\udde6\ud83c\uddf9", 60 "demonyms": { 61 "eng": { 62 "f": "Austrian", 63 "m": "Austrian" 64 }, 65 "fra": { 66 "f": "Autrichienne", 67 "m": "Autrichien" 68 } 69 } 70 } 71 */ 72 73var euroCountries = CountryQuery.find('currencies', 'EUR') 74 75// euroCountries will be an array of country objects
Acceptable values for by
are:
tld
currencies
idd
altSpellings
latlng
borders
name.common
name.official
name.native
translations
languages
cca2
ccn3
cca3
capital
cioc
region
subregion
demonyms
landlocked
area
findByArea(area)
Find country by its area.
Return value is the same as find.
findByAltSpelling(altSpelling)
Find country by alternative spellings of its name.
Return value is the same as find.
findByBorders(borders)
Find country by countries that it borders
Return value is the same as find.
findByIdd(idd)
Find country by telephone calling code.
Return value is the same as find.
findByCapital(capital)
Find country by its capital city.
Return value is the same as find.
findByCca2(cca2)
Find country by 2-letter country code.
Return value is the same as find.
findByCca3(cca3)
Find country by 3-letter country code.
Return value is the same as find.
findByCcn3(ccn3)
Find country by numeric country code.
Return value is the same as find.
findByCioc(cioc)
Find country by 3-letter International Olympic Commitee country code.
Return value is the same as find.
findByCurrency(currency)
Find country by currency.
Return value is the same as find.
findByDemonym(demonym)
Find country by one of the demonyms used for its citizens.
Return value is the same as find.
findByLandlocked(landlocked)
Find country by whether or not it is landlocked.
Return value is the same as find.
findByLanguage(language)
Find country by its language.
Return value is the same as find.
findByNameCommon(name)
Find country by its common name.
Return value is the same as find.
findByNameNative(name)
Find country by its native name.
Return value is the same as find.
findByNameOfficial(name)
Find country by its official name.
Return value is the same as find.
findByRegion(region)
Find country by the region it is located in.
Return value is the same as find.
findBySubregion(subregion)
Find country by subregion it is located in.
Return value is the same as find.
findByTld(tld)
Find country by top level domain.
Return value is the same as find.
findByTranslation(translation)
Find country by translations of its name.
Return value is the same as find.
Thanks
This project would not exist without the work of the contributors to the world-countries data set.
License
Copyright (C) 2015, Peter Thompson peter.thompson@dunelm.org.uk
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
5 existing vulnerabilities detected
Details
- 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-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/petert82/country-query/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/petert82/country-query/ci.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
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
license file not detected
Details
- Warn: project does not have a license file
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 16 are checked with a SAST tool
Score
2.7
/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 country-query
@ladjs/country-language
Maintained fork of country-language with zero-dependencies. Query languages spoken to a country or countries where people speak a language.
country-language
Query languages spoken to a country or countries where people speak a language.
country-data-query
Easy and powerful library for query complex country and regions data in simple and effective way by country code, currency code, dial code in various filters.
@dear-rama/country-query
A javascript query API for world-countries data