country.
country. provides all kinds of data on countries. It offers the following information:
- ISO-3611-1/2/3 code
- International Olympic Committee Code (IOC)
- Spoken languages
- Used currencies
- Calling codes
- Country Flag as an Emoji
- Names in the following languages:
Code | Language |
---|
ar | Arabic |
cs | Czech |
de | German |
en | English |
et | Estonian |
fi | Finnish |
fr | French |
it | Italian |
nb | Norwegian Bokmål |
nn | Norwegian Nynorsk |
nl | Dutch |
pl | Polish |
pt | Portuguese |
ru | Russian |
sv | Swedish |
tr | Turkish |
zh | Chinese |
This library also classifies countries into regions. The following regions are supported:
-
Asia (Central + Southern + Southeast + East + Western)
-
Central Asia
-
Southern Asia
-
Southeast Asia
-
East Asia
-
Western Asia
-
Africa (Central + North + Southern + East + West)
-
Central Africa
-
North Africa
-
Southern Africa
-
East Africa
-
West Africa
-
Europe (Northern + Southern + Eastern + Western)
-
Northern Europe
-
Southern Europe
-
Eastern Europe
-
Western Europe
-
America (Central + Northern + Southern)
-
Central America
-
Northern America
-
South America
-
Other
-
Australia
-
Melanesia
-
Micronesia
-
Polynesia
-
Antartica
-
Caribbean
Usage
Require country. in your project.
'use strict';
const country = require('countryinfo');
ISO 3166-1 codes
country.iso1('DE');
country.iso1('DEU');
country.iso1('Germany');
country.iso1('Deutschland', 'de');
country.iso2('276');
country.iso2('DEU');
country.iso2('Germany');
country.iso2('Deutschland', 'de');
country.iso3('276');
country.iso3('DE');
country.iso3('Germany');
country.iso3('Deutschland', 'de');
IOC
country.ioc('276');
country.ioc('DE');
country.ioc('DEU');
country.ioc('Germany');
country.ioc('Deutschland', 'de');
Languages
country.languages('276');
country.languages('DE');
country.languages('DEU');
country.languages('Germany');
country.languages('Deutschland', 'de');
Currencies
country.currencies('276');
country.currencies('DE');
country.currencies('DEU');
country.currencies('Germany');
country.currencies('Deutschland', 'de');
Country data
country.data('276');
country.data('DE');
country.data('DEU');
country.data('Germany');
country.data('Deutschland', 'de');
Regions
country.regions();
country.regionsData();
country.regions('europe');
country.regions('Central Asia');
country.regionsData('europe');
country.regionsData('Central Asia');
Contribution & Data Sources
If you want to add additional country names to the list, feel free to do so in the /lib/data/names.json
file. The structure should be clear.
{
"DE": { // ISO 3166-1 alpha-2 identifier
"en": ["Germany"], // array of to be added names in the set locale
"ar": [" ألمانيا"]
}
}
To import the data into the library, run make
in the root directory. This recreates the /lib/data/masterData.json
file.
Data sources
I don't need a JS library, I just need the data.
Run make
in the root directory of the project and copy the /lib/data/masterData.json
file. This file contains all the mentioned data.
Build / Test / Update
In package json:
npm test
- run testsnpm run cleaner
- update master data