ISO 3166 (国家代码和其分区代码标准)
[![Build][build-badge]][build] [![Coverage][coverage-badge]][coverage] [![Downloads][downloads-badge]][downloads] [![Size][size-badge]][size]
Info on [ISO 3166][i3166].
This package contains info on ISO 3166. The purpose of ISO 3166 is to define internationally recognized codes that we can use when we refer to countries and their subdivisions.
ISO 3166 includes three parts:
US USA United States of America)US-CA for
California in US USA United States of America)BUMM to refer
to when BU BUR Burma revised its name to MM MMR Myanmar in 1989)While the information in ISO 3166 is well known and freely available through for example WikiPedia, it is not freely available in a machine readable format from ISO. That’s where this project comes in: it scrapes WikiPedia.
ISO 3166 is closely tied to the work of the United Nations: the names for countries stem from the UN and ISO 3166 maps to numerical [UN M49][um49] codes and vice versa. UN M49 also includes information on bigger regions between our earth and countries.
This project includes all three parts of ISO 3166 as separate exports:
iso31661][1]
— countries: list of [assigned][] ISO 3166-1 entriesiso31662][2]
— subdivisions: list of ISO 3166-2 entriesiso31663][3]
— revisions: list of ISO 3166-3 entriesAdditionally, a list of reserved ISO 3166-1 entries is available:
iso31661Reserved][1-reserved]
— list of [reserved][] ISO 3166-1 entriesFinally, indexes are available to map between different codes:
iso31661Alpha2ToAlpha3][1-a2-to-1-a3]
— map ISO 3166-1 alpha-2 codes to ISO 3166-1 alpha-3 codesiso31661Alpha2ToNumeric][1-a2-to-1-n]
— map ISO 3166-1 alpha-2 codes to ISO 3166-1 numeric (UN M49) codesiso31661Alpha3ToAlpha2][1-a3-to-1-a2]
— map ISO 3166-1 alpha-3 codes to ISO 3166-1 alpha-2 codesiso31661NumericToAlpha2][1-n-to-1-a2]
— map ISO 3166-1 numeric (UN M49) codes to ISO 3166-1 alpha-2 codesYou can use this package any time you have to deal with countries and subdivisions or ISO 3166 in particular. The alphabetical codes from ISO 3166 are more useful to humans, but the numerical codes from [UN M49][um49] are more resilient to changes. UN M49 also encodes regions bigger than countries, such as (sub)contintents.
Show ISO 3166-1 alpha-2 code matrix
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
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
YM
YN
YO
YP
YQ
YR
YS
YT
YU
YV
YW
YX
YY
YZ
Z
ZA
ZB
ZC
ZD
ZE
ZF
ZG
ZH
ZI
ZJ
ZK
ZL
ZM
ZN
ZO
ZP
ZQ
ZR
ZS
ZT
ZU
ZV
ZW
ZX
ZY
ZZThis package is [ESM only][esm]. In Node.js (version 14.14+, 16.0+), install with [npm][]:
npm install iso-3166In Deno with [esm.sh][esmsh]:
import * as iso3166 from 'https://esm.sh/iso-3166@4'In browsers with [esm.sh][esmsh]:
See examples below.
This package exports the identifiers iso31661, iso31661Alpha2ToAlpha3,
iso31661Alpha2ToNumeric, iso31661Alpha3ToAlpha2, iso31661NumericToAlpha2,
iso31661Reserved, iso31662, iso31663.
There is no default export.
iso31661List of assigned ISO 3166-1 countries ([Array][1-entry]).
import {iso31661} from 'iso-3166'
console.log(iso31661)Yields:
[
{state: 'assigned', alpha2: 'AD', alpha3: 'AND', numeric: '020', name: 'Andorra'},
{state: 'assigned', alpha2: 'AE', alpha3: 'ARE', numeric: '784', name: 'United Arab Emirates'},
{state: 'assigned', alpha2: 'AF', alpha3: 'AFG', numeric: '004', name: 'Afghanistan'},
{state: 'assigned', alpha2: 'AG', alpha3: 'ATG', numeric: '028', name: 'Antigua and Barbuda'},
{state: 'assigned', alpha2: 'AI', alpha3: 'AIA', numeric: '660', name: 'Anguilla'},
// …
]iso31661ReservedList of reserved ISO 3166-1 countries ([Array][1-entry]).
import {iso31661Reserved} from 'iso-3166'
console.log(iso31661Reserved)Yields:
[
{state: 'exceptionally-reserved', alpha2: 'AC', name: 'Ascension Island'},
{state: 'transitionally-reserved', alpha2: 'AN', name: 'Netherlands Antilles'},
{state: 'indeterminately-reserved', alpha2: 'AP', name: 'African Regional Industrial Property Organization'},
{state: 'transitionally-reserved', alpha2: 'BU', name: 'Burma'},
{state: 'indeterminately-reserved', alpha2: 'BX', name: 'Benelux Trademarks and Designs Office'},
// …
]iso31662List of ISO 3166-2 subdivisions ([Array][2-entry]).
import {iso31662} from 'iso-3166'
console.log(iso31662)Yields:
[
{code: 'AD-02',暂无开放 Issues,或尚未同步最近议题。