Comprehensive country codes: ISO 3166, ITU, ISO 4217 currency codes and many more

core

Files Size Format Created Updated License Source
2 920kB csv zip 5 days ago public_domain_dedication_and_license United Nations Protocol and Liaison Service Unicode Common Locale Data Repository (CLDR) Project United Nations Department of Ecoonomic and Social Affairs Statistics Division SIX Interbank Clearing Ltd (on behalf of ISO) Statoids Geonames US Securities and Exchange Commission
Comprehensive country code information, including ISO 3166 codes, ITU dialing codes, ISO 4217 currency codes, and many others. Provided as a Tabular Data Package: view datapackage Data Data are fetched from multiple sources: Official formal and short names (in English, French, Spanish, Arabic, read more
Download

Data Files

File Description Size Last changed Download Other formats
country-codes [csv] 127kB country-codes [csv] country-codes [json] (518kB)
datapackage_zip [zip] Compressed versions of dataset. Includes normalized CSV and JSON data with original data and datapackage.json. 148kB datapackage_zip [zip]

country-codes  

This is a preview version. There might be more data in the original version.

Field information

Field Name Order Type (Format) Description
official_name_ar 1 string Country or Area official Arabic short name from UN Statistics Divsion
official_name_cn 2 string Country or Area official Chinese short name from UN Statistics Divsion
official_name_en 3 string Country or Area official English short name from UN Statistics Divsion
official_name_es 4 string Country or Area official Spanish short name from UN Statistics Divsion
official_name_fr 5 string Country or Area official French short name from UN Statistics Divsion
official_name_ru 6 string Country or Area official Russian short name from UN Statistics Divsion
ISO3166-1-Alpha-2 7 string Alpha-2 codes from ISO 3166-1
ISO3166-1-Alpha-3 8 string Alpha-3 codes from ISO 3166-1 (synonymous with World Bank Codes)
ISO3166-1-numeric 9 string Numeric codes from ISO 3166-1
ISO4217-currency_alphabetic_code 10 string ISO 4217 currency alphabetic code
ISO4217-currency_country_name 11 string ISO 4217 country name
ISO4217-currency_minor_unit 12 string ISO 4217 currency number of minor units
ISO4217-currency_name 13 string ISO 4217 currency name
ISO4217-currency_numeric_code 14 string ISO 4217 currency numeric code
M49 15 number UN Statistics M49 numeric codes (nearly synonymous with ISO 3166-1 numeric codes, which are based on UN M49. ISO 3166-1 does not include Channel Islands or Sark, for example)
UNTERM Arabic Formal 16 string Country's formal Arabic name from UN Protocol and Liaison Service
UNTERM Arabic Short 17 string Country's short Arabic name from UN Protocol and Liaison Service
UNTERM Chinese Formal 18 string Country's formal Chinese name from UN Protocol and Liaison Service
UNTERM Chinese Short 19 string Country's short Chinese name from UN Protocol and Liaison Service
UNTERM English Formal 20 string Country's formal English name from UN Protocol and Liaison Service
UNTERM English Short 21 string Country's short English name from UN Protocol and Liaison Service
UNTERM French Formal 22 string Country's formal French name from UN Protocol and Liaison Service
UNTERM French Short 23 string Country's short French name from UN Protocol and Liaison Service
UNTERM Russian Formal 24 string Country's formal Russian name from UN Protocol and Liaison Service
UNTERM Russian Short 25 string Country's short Russian name from UN Protocol and Liaison Service
UNTERM Spanish Formal 26 string Country's formal Spanish name from UN Protocol and Liaison Service
UNTERM Spanish Short 27 string Country's short Spanish name from UN Protocol and Liaison Service
CLDR display name 28 string Country's customary English short name (CLDR)
Capital 29 string Capital city from Geonames
Continent 30 string Continent from Geonames
DS 31 string Distinguishing signs of vehicles in international traffic
Developed / Developing Countries 32 string Country classification from United Nations Statistics Division
Dial 33 string Country code from ITU-T recommendation E.164, sometimes followed by area code
EDGAR 34 string EDGAR country code from SEC
FIFA 35 string Codes assigned by the Fédération Internationale de Football Association
FIPS 36 string Codes from the U.S. standard FIPS PUB 10-4
GAUL 37 string Global Administrative Unit Layers from the Food and Agriculture Organization
Geoname ID 38 number Geoname ID
Global Code 39 string Country classification from United Nations Statistics Division
Global Name 40 string Country classification from United Nations Statistics Division
IOC 41 string Codes assigned by the International Olympics Committee
ITU 42 string Codes assigned by the International Telecommunications Union
Intermediate Region Code 43 string Country classification from United Nations Statistics Division
Intermediate Region Name 44 string Country classification from United Nations Statistics Division
Land Locked Developing Countries (LLDC) 45 string Country classification from United Nations Statistics Division
Languages 46 string Languages from Geonames
Least Developed Countries (LDC) 47 string Country classification from United Nations Statistics Division
MARC 48 string MAchine-Readable Cataloging codes from the Library of Congress
Region Code 49 string Country classification from United Nations Statistics Division
Region Name 50 string Country classification from United Nations Statistics Division
Small Island Developing States (SIDS) 51 string Country classification from United Nations Statistics Division
Sub-region Code 52 string Country classification from United Nations Statistics Division
Sub-region Name 53 string Country classification from United Nations Statistics Division
TLD 54 string Top level domain from Geonames
WMO 55 string Country abbreviations by the World Meteorological Organization
is_independent 56 string Country status, based on the CIA World Factbook

datapackage_zip  

This is a preview version. There might be more data in the original version.

Read me

goodtables.io

Comprehensive country code information, including ISO 3166 codes, ITU dialing codes, ISO 4217 currency codes, and many others. Provided as a Tabular Data Package: view datapackage

Data

Data are fetched from multiple sources:

Official formal and short names (in English, French, Spanish, Arabic, Chinese, and Russian) are from United Nations Protocol and Liaison Service

Customary English short names are from Unicode Common Locale Data Repository (CLDR) Project.

Note: CLDR shorter names “ZZ-alt-short” are used when available

ISO 3166 official short names (in English, French, Spanish, Arabic, Chinese, and Russian) are from United Nations Department of Ecoonomic and Social Affairs Statistics Division

ISO 4217 currency codes are from currency-iso.org

Many other country codes are from statoids.com

Special thanks to Gwillim Law for his excellent statoids.com site (some of the field descriptions are excerpted from his site), which is more up-to-date than most similar resources and is much easier to scrape than multiple Wikipedia pages.

Capital cities, languages, continents, TLDs, and geonameid are from geonames.org

EDGAR codes are from sec.gov

Preparation

This package includes Python scripts to fetch current country information from various data sources and output CSV of combined country code information.

CSV output is provided via the in2csv and csvcut utilities from csvkit

NOTE/TODO: currently, preparation requires manual process to download and rename 6 CSV files from https://unstats.un.org/unsd/methodology/m49/overview/

data/country-codes.csv

Install requirements:

pip install -r scripts/requirements.pip

Run GNU Make to generate data file:

make country-codes.csv

License

This material is licensed by its maintainers under the Public Domain Dedication and License.

Nevertheless, it should be noted that this material is ultimately sourced from ISO and other standards bodies and their rights and licensing policies are somewhat unclear. As this is a short, simple database of facts there is a strong argument that no rights can subsist in this collection. However, ISO state on their site:

ISO makes the list of alpha-2 country codes available for internal use and non-commercial purposes free of charge.

This carries the implication (though not spelled out) that other uses are not permitted and that, therefore, there may be rights preventing further general use and reuse.

If you intended to use these data in a public or commercial product, please check the original sources for any specific restrictions.

Import into your tool

If you are using R here's how to get the data you want quickly loaded:

install.packages("jsonlite")
library("jsonlite")

json_file <- "http://datahub.io/core/country-codes/datapackage.json"
json_data <- fromJSON(paste(readLines(json_file), collapse=""))

# access csv file by the index starting from 1
path_to_file = json_data$resources[[1]]$path
data <- read.csv(url(path_to_file))
print(data)

In order to work with Data Packages in Pandas you need to install the Frictionless Data data package library and the pandas extension:

pip install datapackage
pip install jsontableschema-pandas

To get the data run following code:

import datapackage

data_url = "http://datahub.io/core/country-codes/datapackage.json"

# to load Data Package into storage
storage = datapackage.push_datapackage(data_url, 'pandas')

# data frames available (corresponding to data files in original dataset)
storage.buckets

# you can access datasets inside storage, e.g. the first one:
storage[storage.buckets[0]]

For Python, first install the `datapackage` library (all the datasets on DataHub are Data Packages):

pip install datapackage

To get Data Package into your Python environment, run following code:

from datapackage import Package

package = Package('http://datahub.io/core/country-codes/datapackage.json')

# get list of resources:
resources = package.descriptor['resources']
resourceList = [resources[x]['name'] for x in range(0, len(resources))]
print(resourceList)

data = package.resources[0].read()
print(data)

If you are using JavaScript, please, follow instructions below:

Install data.js module using npm:

  $ npm install data.js

Once the package is installed, use the following code snippet:

const {Dataset} = require('data.js')

const path = 'http://datahub.io/core/country-codes/datapackage.json'

// We're using self-invoking function here as we want to use async-await syntax:
(async () => {
  const dataset = await Dataset.load(path)

  // Get the first data file in this dataset
  const file = dataset.resources[0]
  // Get a raw stream
  const stream = await file.stream()
  // entire file as a buffer (be careful with large files!)
  const buffer = await file.buffer
})()

Install the datapackage library created specially for Ruby language using gem:

gem install datapackage

Now get the dataset and read the data:

require 'datapackage'

path = 'http://datahub.io/core/country-codes/datapackage.json'

package = DataPackage::Package.new(path)
# So package variable contains metadata. You can see it:
puts package

# Read data itself:
resource = package.resources[0]
data = resource.read
puts data
Datapackage.json