1.0.0 • Published 8 months ago

@andreasnicolaou/country-kit v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Country Kit - Comprehensive Country Data

A comprehensive package for working with country data. Includes ISO codes, names in multiple languages, capitals, currencies, continents and more.

Installation

npm install @andreasnicolaou/country-kit

Usage

Importing the Library

import { CountryKit } from '@andreasnicolaou/country-kit';

Get all Countries

const countries = CountryKit.getAllCountries();
console.log(countries); // Logs all countries

Get countries by Continent

const countries = CountryKit.getCountriesByContinent('Asia');
console.log(countries); // Logs all countries with continent 'Asia'

Get countries by Currency

const countries = CountryKit.getCountriesByCurrency('USD');
console.log(countries); // Logs all countries with currency 'USD'

Get countries by Language

const countries = CountryKit.getCountriesByLanguage('Spanish');
console.log(countries); // Logs all countries with language 'Spanish'

Get country by Code

const country = CountryKit.getCountryByCode('us');
console.log(country); // Logs US country data

Country Object Structure

PropertyTypeDescription
codestring \| nullThe two-letter ISO 3166-1 country code.
code3string \| nullThe three-letter ISO 3166-1 country code.
numeric_codestring \| nullThe numeric ISO 3166-1 country code.
namestring \| nullThe common name of the country.
official_namestring \| nullThe official name of the country.
native_namestring \| nullThe native name of the country.
translationsRecord<'ara' \| 'bre' \| 'ces'\| 'chn'\| 'cym'\| 'deu'\| 'esp'\| 'est'\| 'fin'\| 'fra'\| 'grc'\| 'hrv'\| 'hun'\| 'idn'\| 'ind'\| 'ita'\| 'jpn'\| 'kor'\| 'nld'\| 'per'\| 'pol'\| 'por'\| 'prt'\| 'rus'\| 'sau'\| 'slk'\| 'spa'\| 'srp'\| 'swe'\| 'tha'\| 'tur'\| 'urd'\| 'usa'\| 'vnm'\| 'zho' , string>A record of country names translated into various languages.
capitalstring \| nullThe capital city of the country.
continentstring \| nullThe continent where the country is located.
subregionstring \| nullThe subregion where the country is located.
tldstring[]An array of top-level domains associated with the country.
flagstring \| nullThe URL of the country’s flag.
emojistring \| nullThe emoji representation of the country's flag.
currency{ code: string; name: string; symbol: string }[]An array of currency objects with code, name, and symbol.
languagesstring[]An array of official languages spoken in the country.
timezonesstring[]An array of timezones used in the country.
phone_codestring \| nullThe international dialing code of the country.
latlngnumber[] \| nullThe latitude and longitude coordinates of the country.
populationnumber \| nullThe estimated population of the country.
areanumber \| nullThe total land area of the country in square kilometers.
drives_on'left' \| 'right' \| nullThe side of the road vehicles drive on in the country.
demonymstring \| nullThe demonym used for people from the country.
world_sharestring \| nullThe percentage of the world’s population living in this country.

Data Sources

Country data have been generated using the following sources:

  • REST Countries API - Providing detailed country information, including ISO codes, names, capitals, currencies, and languages.
  • Worldometer - Providing population, area, and demographic statistics.

Contributing

Contributions are welcome! If you encounter issues or have ideas to enhance the library, feel free to submit an issue or pull request.