diva-mobile-countries-code
v0.1.5
Published
List of contries data with alpha-2, alpha-3 and number codes
Downloads
12
Maintainers
Keywords
Readme
countries-code
Data fetched from https://unstats.un.org/unsd/methodology/m49/ (UN) and from Wikipedia
List of countries:
With country object containing Alpha-2 code (e.g.IE
), Alpha-3 code (e.g. IRL
), and Number codes.
Example
const countriesQuery = require("countries-code");
console.log(countriesQuery.allCountriesList());
/*
[....,
{
"country_name_en": "Ireland",
"country_name_fr": "Irlande (l')",
"alpha2": "IE",
"alpha3": "IRL",
"number": "372"
},...]
*/
console.log(countriesQuery.getAllAlphaTwoCodes());
// ["AF",.....]
console.log(countriesQuery.getAllAlphaThreeCodes());
// ["AFG",.....]
// Use getCountry to get country name by alpha code-2 or 3
console.log(countriesQuery.getCountry("IE"));
// "Ireland"
console.log(countriesQuery.getCountry("IRL"));
// "Ireland"
// Use convertAlphaCode to convert alpha code-2 to 3 or vice versa
console.log(countriesQuery.convertAlphaCode("IE"));
// "IRL"
console.log(countriesQuery.convertAlphaCode("IRL"));
// "IE"
import { countriesQuery } from "countries-code";
console.log(countriesQuery.allCountriesList());
/*
[....,
{
"country_name_en": "Ireland",
"country_name_fr": "Irlande (l')",
"alpha2": "IE",
"alpha3": "IRL",
"number": "372"
},...]
*/
console.log(countriesQuery.getAllAlphaTwoCodes());
// ["AF",.....]
console.log(countriesQuery.getAllAlphaThreeCodes());
// ["AFG",.....]
// Use getCountry to get country name by alpha code-2 or 3
console.log(countriesQuery.getCountry("IE"));
// "Ireland"
console.log(countriesQuery.getCountry("IRL"));
// "Ireland"
// Use convertAlphaCode to convert alpha code-2 to 3 or vice versa
console.log(countriesQuery.convertAlphaCode("IE"));
// "IRL"
console.log(countriesQuery.convertAlphaCode("IRL"));
// "IE"
License
MIT
:incoming_envelope: :four_leaf_clover: