Comprehensive world countries data including names, codes, capitals, currencies, languages, and more. Available for TypeScript, PHP, Ruby, and Python.
- ๐ Complete Coverage: Data for all world countries
- ๐๏ธ Rich Information: Country names, native names, capitals, currencies, languages, phone codes, continents, and emoji flags
- ๐ Smart Search: Search by name, code, continent, currency, language, or phone code
- ๐ฆ Multi-Language Support: Available for TypeScript/JavaScript, PHP, Ruby, and Python
- ๐ฏ Type-Safe: Full TypeScript support with type definitions
- โก Lightweight: Zero dependencies, pure JSON data
- ๐ ISO Standards: Follows ISO 3166-1 alpha-2 country codes
npm install @devmehq/world-countries
composer require devmehq/world-countries
gem install world_countries
pip install world-countries
import { WorldCountries } from '@devmehq/world-countries';
const countries = new WorldCountries();
// Get all countries
const allCountries = countries.getAll();
// Get country by code
const usa = countries.getByCode('US');
console.log(usa);
// { name: 'United States', native: 'United States', phone: [1], ... }
// Search countries
const results = countries.search('united');
// Get countries by continent
const europeanCountries = countries.getByContinent('EU');
// Get countries by currency
const euroCountries = countries.getByCurrency('EUR');
// Get countries by language
const spanishCountries = countries.getByLanguage('es');
// Get countries by phone code
const countriesWithCode1 = countries.getByPhoneCode(1);
<?php
use DevMe\WorldCountries\WorldCountries;
$countries = new WorldCountries();
// Get all countries
$allCountries = $countries->getAll();
// Get country by code
$usa = $countries->getByCode('US');
// Search countries
$results = $countries->search('united');
// Get countries by continent
$europeanCountries = $countries->getByContinent('EU');
// Get countries by currency
$euroCountries = $countries->getByCurrency('EUR');
require 'world_countries'
countries = WorldCountries::Countries.new
# Get all countries
all_countries = countries.all
# Get country by code
usa = countries.get_by_code('US')
# Search countries
results = countries.search('united')
# Get countries by continent
european_countries = countries.get_by_continent('EU')
# Get countries by currency
euro_countries = countries.get_by_currency('EUR')
from world_countries import WorldCountries
countries = WorldCountries()
# Get all countries
all_countries = countries.get_all()
# Get country by code
usa = countries.get_by_code('US')
# Search countries
results = countries.search('united')
# Get countries by continent
european_countries = countries.get_by_continent('EU')
# Get countries by currency
euro_countries = countries.get_by_currency('EUR')
Each country contains the following information:
{
"US": {
"name": "United States",
"native": "United States",
"phone": [1],
"continent": "NA",
"capital": "Washington D.C.",
"currency": ["USD", "USN", "USS"],
"languages": ["en"],
"emoji": "๐บ๐ธ",
"emojiU": "U+1F1FA U+1F1F8"
}
}
- name: Country name in English
- native: Country name in its native language
- phone: Array of international calling codes
- continent: Continent code (AF, AN, AS, EU, NA, OC, SA)
- capital: Capital city name
- currency: Array of currency codes (ISO 4217)
- languages: Array of language codes (ISO 639-1)
- emoji: Country flag emoji
- emojiU: Unicode representation of the flag emoji
All implementations provide these core methods:
Method | Description | Returns |
---|---|---|
getAll() / get_all() |
Get all countries | Object/Dict with all countries |
getByCode(code) / get_by_code(code) |
Get country by ISO code | Country object or null |
getByName(name) / get_by_name(name) |
Get country by name | Country object with code or null |
getByContinent(continent) / get_by_continent(continent) |
Get countries by continent | Object/Dict of matching countries |
getByCurrency(currency) / get_by_currency(currency) |
Get countries by currency | Object/Dict of matching countries |
getByLanguage(language) / get_by_language(language) |
Get countries by language | Object/Dict of matching countries |
getByPhoneCode(code) / get_by_phone_code(code) |
Get countries by phone code | Object/Dict of matching countries |
search(query) |
Search countries by name/code/capital | Object/Dict of matching countries |
getAllCodes() / get_all_codes() |
Get all country codes | Array/List of codes |
getAllNames() / get_all_names() |
Get all country names | Array/List of names |
getAllCapitals() / get_all_capitals() |
Get all unique capitals | Array/List of capitals |
getAllContinents() / get_all_continents() |
Get all unique continents | Array/List of continents |
getAllCurrencies() / get_all_currencies() |
Get all unique currencies | Array/List of currencies |
getAllLanguages() / get_all_languages() |
Get all unique languages | Array/List of languages |
count() |
Get total number of countries | Number |
- AF: Africa
- AN: Antarctica
- AS: Asia
- EU: Europe
- NA: North America
- OC: Oceania
- SA: South America
const countries = new WorldCountries();
// Get all English-speaking countries
const englishSpeaking = countries.getByLanguage('en');
// Get all countries using US Dollar
const usdCountries = countries.getByCurrency('USD');
// Get all Asian countries
const asianCountries = countries.getByContinent('AS');
// Search for countries with "island" in the name
const islandNations = countries.search('island');
// Get country by multiple criteria
const spain = countries.getByCode('ES');
const spainByName = countries.getByName('Spain');
// Get statistics
console.log(`Total countries: ${countries.count()}`);
console.log(`Total currencies: ${countries.getAllCurrencies().length}`);
console.log(`Total languages: ${countries.getAllLanguages().length}`);
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
Created and maintained by DevMe
- World Currencies - Comprehensive world currencies data
For issues and feature requests, please use the GitHub issues page.