Convert Figma logo to code with AI

annexare logoCountries

Countries, Languages & Continents data (capital and currency, native name, calling codes).

1,254
427
1,254
17

Top Related Projects

Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats.

Constantly updated lists of world countries and their associated alpha-2, alpha-3 and numeric country codes as defined by the ISO 3166 standard, available in CSV, JSON , PHP, SQL and XML formats, in multiple languages and with national flags included; also available are the ISO 3166-2 codes of provinces/ states associated with the countries

🌍 Discover our global repository of countries, states, and cities! 🏙️ Get comprehensive data in JSON, SQL, PSQL, SQLSERVER, MONGODB, SQLITE, XML, YAML, and CSV formats. Access ISO2, ISO3 codes, country code, capital, native language, timezones (for countries), and more. #countries #states #cities

A simple data of the world by country each in JSON format.

Quick Overview

The annexare/Countries repository is a comprehensive dataset of world countries, languages, and currencies. It provides detailed information in multiple formats, including JSON, SQL, and CSV, making it easy to integrate into various projects. The data is regularly updated and includes ISO codes, capital cities, phone codes, and more.

Pros

  • Extensive dataset covering countries, languages, and currencies
  • Available in multiple formats (JSON, SQL, CSV) for easy integration
  • Regularly updated with accurate information
  • Includes additional data like capital cities, phone codes, and timezones

Cons

  • May require manual updates in projects to stay current with the latest data
  • Some less common or disputed territories might be missing or have incomplete information
  • Large dataset size may impact performance in some applications
  • Potential for discrepancies between different data formats if not synchronized properly

Code Examples

// Importing the countries data in a JavaScript project
import countries from '@annexare/countries';

console.log(countries.US); // Outputs information about the United States
# Using the countries data in a Python project
import json

with open('countries.json', 'r') as f:
    countries = json.load(f)

print(countries['GB']) # Outputs information about the United Kingdom
-- Querying the countries data in SQL
SELECT name, capital, currency
FROM countries
WHERE continent = 'Europe';

Getting Started

To use the annexare/Countries dataset in your project:

  1. Install via npm (for JavaScript projects):

    npm install @annexare/countries
    
  2. Or download the desired format (JSON, SQL, CSV) from the GitHub repository.

  3. Import or load the data into your project:

    import countries from '@annexare/countries';
    // Use the data in your application
    
  4. For other languages or formats, load the data according to your project's requirements.

Competitor Comparisons

Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

Pros of Countries

  • More comprehensive data structure with detailed information for each country
  • Supports multiple languages and localization
  • Provides additional features like currency and timezone data

Cons of Countries

  • Larger file size due to more extensive data
  • May require more setup and configuration
  • Potentially slower performance for simple queries due to data complexity

Code Comparison

Countries:

use Rinvex\Country\Country;

$country = new Country('us');
echo $country->getName(); // United States
echo $country->getCapital(); // Washington, D.C.

annexare/Countries:

const countries = require('countries-list');

console.log(countries.countries.US.name); // United States
console.log(countries.countries.US.capital); // Washington

Summary

Countries offers a more feature-rich and detailed dataset, making it suitable for applications requiring in-depth country information and localization support. However, this comes at the cost of increased complexity and potentially larger file sizes.

annexare/Countries provides a simpler, lightweight alternative with basic country data, which may be preferable for projects with minimal country information requirements or where performance is a primary concern.

The choice between the two repositories depends on the specific needs of your project, balancing between data comprehensiveness and simplicity.

:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats.

Pros of country-list

  • Extensive language support with translations for country names in 260+ languages
  • Includes various data formats (JSON, CSV, SQL, XML, etc.)
  • Regular updates and maintenance

Cons of country-list

  • Larger file size due to extensive language support
  • Lacks additional country data (e.g., capitals, currencies, phone codes)
  • More complex structure for simple use cases

Code Comparison

country-list (JSON format):

{
  "AF": "Afghanistan",
  "AL": "Albania",
  "DZ": "Algeria"
}

Countries (JSON format):

[
  {"name": "Afghanistan", "code": "AF", "capital": "Kabul", "currency": "AFN"},
  {"name": "Albania", "code": "AL", "capital": "Tirana", "currency": "ALL"},
  {"name": "Algeria", "code": "DZ", "capital": "Algiers", "currency": "DZD"}
]

Summary

Countries offers a more compact dataset with additional country information, making it suitable for projects requiring comprehensive country data. country-list excels in multilingual support and various data formats, making it ideal for internationalization projects. The choice between the two depends on specific project requirements, such as language support needs or the desire for additional country details.

Constantly updated lists of world countries and their associated alpha-2, alpha-3 and numeric country codes as defined by the ISO 3166 standard, available in CSV, JSON , PHP, SQL and XML formats, in multiple languages and with national flags included; also available are the ISO 3166-2 codes of provinces/ states associated with the countries

Pros of world_countries

  • More comprehensive data, including additional fields like ISO numeric codes and top-level domains
  • Offers data in multiple formats (JSON, CSV, SQL, XML)
  • Regular updates and maintenance

Cons of world_countries

  • Lacks some features like continents and time zones
  • Less customizable data structure compared to Countries

Code Comparison

world_countries (JSON format):

{
  "id": "AND",
  "alpha2": "AD",
  "alpha3": "AND",
  "name": "Andorra",
  "capital": "Andorra la Vella",
  "currency": {
    "code": "EUR",
    "name": "Euro",
    "symbol": "€"
  }
}

Countries:

{
  "name": "Andorra",
  "native": "Andorra",
  "phone": "376",
  "continent": "EU",
  "capital": "Andorra la Vella",
  "currency": ["EUR"],
  "languages": ["ca"],
  "emoji": "🇦🇩",
  "emojiU": "U+1F1E6 U+1F1E9"
}

Both repositories provide valuable country data, but they cater to different needs. world_countries offers a wider range of data formats and more comprehensive information, while Countries includes additional fields like continents, languages, and emoji representations. The choice between the two depends on the specific requirements of your project and the desired data structure.

🌍 Discover our global repository of countries, states, and cities! 🏙️ Get comprehensive data in JSON, SQL, PSQL, SQLSERVER, MONGODB, SQLITE, XML, YAML, and CSV formats. Access ISO2, ISO3 codes, country code, capital, native language, timezones (for countries), and more. #countries #states #cities

Pros of countries-states-cities-database

  • More comprehensive data, including states and cities
  • Regular updates and maintenance
  • Available in multiple formats (JSON, SQL, CSV)

Cons of countries-states-cities-database

  • Larger file size due to more detailed data
  • May require more processing for simple country-only use cases
  • Less focused on specific country properties (e.g., languages, currencies)

Code comparison

countries-states-cities-database:

{
  "id": 1,
  "name": "Afghanistan",
  "iso3": "AFG",
  "iso2": "AF",
  "numeric_code": "004",
  "phone_code": "93",
  "capital": "Kabul",
  "currency": "AFN",
  "currency_name": "Afghan afghani",
  "currency_symbol": "؋",
  "tld": ".af",
  "native": "افغانستان",
  "region": "Asia",
  "subregion": "Southern Asia",
  "timezones": [
    {
      "zoneName": "Asia/Kabul",
      "gmtOffset": 16200,
      "gmtOffsetName": "UTC+04:30",
      "abbreviation": "AFT",
      "tzName": "Afghanistan Time"
    }
  ],
  "translations": {
    "kr": "아프가니스탄",
    "pt-BR": "Afeganistão",
    "pt": "Afeganistão",
    "nl": "Afghanistan",
    "hr": "Afganistan",
    "fa": "افغانستان",
    "de": "Afghanistan",
    "es": "Afganistán",
    "fr": "Afghanistan",
    "ja": "アフガニスタン",
    "it": "Afghanistan",
    "cn": "阿富汗",
    "tr": "Afganistan"
  },
  "latitude": "33.00000000",
  "longitude": "65.00000000",
  "emoji": "🇦🇫",
  "emojiU": "U+1F1E6 U+1F1EB"
}

Countries:

{
  "name": "Afghanistan",
  "alpha2": "AF",
  "alpha3": "AFG",
  "countryCode": "004",
  "iso_3166_2": "ISO 3166-2:AF",
  "regionCode": "142",
  "subRegionCode": "034",
  "eea": false,
  "centralBank": "Bank of Afghanistan",
  "currencies": ["AFN"],
  "ioc": "AFG",
  "capital": "Kabul",
  "altSpellings": ["AF", "Afġānistān"],
  "region": "Asia",
  "subregion": "Southern Asia",
  "languages": ["pus", "prs"],
  "translations": {
    "cym": "Affganistan",
    "deu": "Afghanistan",
    "fra": "Afghanistan",
    "hrv": "Afganistan",
    "ita": "Afghanistan",
    "jpn": "アフガニスタン",
    "nld": "Afghanistan",
    "por": "Afeganistão",
    "rus": "Афганистан",
    "spa": "Afganistán"
  },
  "latlng": [33, 65],
  "demonym": "Afghan",
  "borders": ["IRN", "PAK", "TKM", "UZB", "TJK", "CHN"],
  "area": 652230
}

A simple data of the world by country each in JSON format.

Pros of country-json

  • Offers more diverse data categories (e.g., GDP, literacy rate, life expectancy)
  • Data is organized into separate JSON files for each category, allowing easier selective use
  • Includes some unique datasets like beer consumption and traffic-related death rates

Cons of country-json

  • Less frequently updated compared to Countries
  • Lacks comprehensive language data and other details provided by Countries
  • Some datasets may be outdated or less reliable due to infrequent updates

Code Comparison

Countries:

{
  "AF": {
    "name": "Afghanistan",
    "native": "افغانستان",
    "phone": "93",
    "continent": "AS",
    "capital": "Kabul",
    "currency": "AFN",
    "languages": ["ps", "uz", "tk"]
  }
}

country-json:

[
  {
    "country": "Afghanistan",
    "city": "Kabul"
  }
]

The Countries repository provides more comprehensive data in a single JSON object, while country-json separates data into multiple files with simpler structures. Countries offers a more detailed and structured approach, whereas country-json focuses on specific categories with easier-to-parse formats.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Countries, Languages & Continents data

Monthly Downloads NPM Packagist CI: JS CI: PHP Twitter

Continents & countries: ISO 3166-1 alpha-2 code (with alpha-2 to alpha-3 set), name, ISO 639-1 languages, capital and ISO 4217 currency codes, native name, calling codes. Lists are available in JSON, CSV and SQL formats. Also, contains separate JSON files with additional country Emoji flags data.

Version 3.0: Breaking changes

Version 3 comes with some data structure changes. It was completely reworked under the hood with TypeScript, ESM exports and Turborepo file structure.

Everything is strongly typed so you can easily use data with auto-complete in your IDE.

Note: If your projects depend on the old structure, carefully specify required versions in your dependencies.

Installation

Package is available via:

  • NPM npm install countries-list
  • Composer / Packagist composer require annexare/countries-list

Usage (version 3.x)

Module exports continents, countries, languages and utility functions.

// Interfaces and types
import type {
  ICountry,
  ICountryData,
  ILanguage,
  TContinentCode,
  TCountryCode,
  TLanguageCode,
} from 'countries-list'

// Main data and utils
import { continents, countries, languages } from 'countries-list'
// Utils
import { getCountryCode, getCountryData, getCountryDataList, getEmojiFlag } from 'countries-list'

// Minimal data in JSON
import countries2to3 from 'countries-list/minimal/countries.2to3.min.json'
import countries3to2 from 'countries-list/minimal/countries.3to2.min.json'
import languageNames from 'countries-list/minimal/languages.native.min'

getCountryCode('Ukraine') // 'UA'
getCountryCode('Україна') // 'UA'
getCountryData('UA') // ICountryData

Built files are in the dist directory of this repository, and packages/countries directory contains source data.

Note: JS build contains ES modules, CommonJS and IIFE (for now)

  • CJS cjs/index.js
  • ESM mjs/index.js
  • IIFE index.iife.js

Data structure examples

const continents = {
  AF: 'Africa',
  AN: 'Antarctica',
  AS: 'Asia',
  EU: 'Europe',
  NA: 'North America',
  OC: 'Oceania',
  SA: 'South America',
}

const countries = {
  // ...
  UA: {
    name: 'Ukraine',
    native: 'Україна',
    phone: [380],
    continent: 'EU',
    capital: 'Kyiv',
    currency: ['UAH'],
    languages: ['uk'],
  },
  // ...
}

const languages = {
  // ...
  uk: {
    name: 'Ukrainian',
    native: 'Українська',
  },
  ur: {
    name: 'Urdu',
    native: 'اردو',
    rtl: 1,
  },
  // ...
}

Contributing to this repository

Everything is generated from strongly typed files in packages/countries/src, including SQL file.

Everything in dist is generated, so please make data related changes ONLY to files from packages/countries, commit them. Use npm run build (or turbo build, turbo test) command to build/test generated files.

Credits

Prepared by Annexare Studio from different public sources. Feel free to use it as you need in your apps or send updates into this public repository. It's under MIT license.

NPM DownloadsLast 30 Days