Welcome to ISO 3166-2's documentation 🌎! ========================================= .. image:: https://img.shields.io/pypi/v/iso3166-2 :target: https://pypi.org/project/iso3166-2/ :alt: iso3166_2 .. image:: https://github.com/amckenna41/iso3166-2/workflows/Building%20and%20Testing/badge.svg :target: https://github.com/amckenna41/iso3166-2/actions?query=workflow:Building%20and%20Testing :alt: pytest .. image:: https://img.shields.io/github/license/amckenna41/iso3166-2 :target: https://opensource.org/licenses/MIT :alt: License: MIT .. image:: https://codecov.io/gh/amckenna41/iso3166-2/branch/main/graph/badge.svg :target: https://codecov.io/gh/amckenna41/iso3166-2 :alt: codecov .. image:: https://upload.wikimedia.org/wikipedia/commons/3/3d/Flag-map_of_the_world_%282017%29.png Introduction ============ **iso3166-2** is a lightweight custom-built Python package, and accompanying RESTfulAPI, that can be used to access all of the world's ISO 3166-2 subdivision data. Here, subdivision can be used interchangeably with regions/states/provinces etc. Currently, the package and API supports data from **250** countries/territories, according to the ISO 3166-1 standard. The software uses another custom-built Python package called |iso3166_updates_repo_link| to ensure all the subdivision data is **accurate, reliable and up-to-date**. The ISO 3166-2 was first published in 1998 and as of December 2025 there are **5,046** codes defined in it. The ISO 3166-2 standard is part of the broader ISO 3166 family, maintained by the International Organization for Standardization (ISO). It provides codes for the names of the principal subdivisions (e.g., provinces or states) of all countries that have codes defined in ISO 3166-1. These codes are widely used in geopolitics, logistics, statistics, and software systems for consistent country and region identification. There are 7 main data attributes available for each subdivision/subdivision code within the **iso3166-2** software: * **Name** - subdivision name, as it is commonly known in English * **Local/other name** - subdivision name in local language or any alternative names its known by * **Latitude/Longitude** - subdivision coordinates * **Flag** - subdivision flag from the custom-built |iso3166_flag_icons_repo_link| repo * **Parent Code** - subdivision's parent code * **Type** - subdivision type, e.g. region, state, canton, parish etc * **History** - historical updates/changes to the subdivision and its data, from the custom-built |iso3166_updates_repo_link| repo Bespoke Features ---------------- There are three main attributes supported by the software that make it stand out and add a significant amount of value and data per subdivision, in comparison to some the other iso3166-2 datasets, these are the **local/other name**, **flag** and **history** attributes. Local/other name ~~~~~~~~~~~~~~~~ The ``localOtherName`` attribute is built from a custom dataset of local language variants and alternative names/nicknames for the **over 5000** subdivisions. In total there are **\>3700** local/other names for the **\>5000** subdivisions. Primarily the attribute contains local language translations for the subdivisions related to the subdivision, but many also include **nicknames** and **other variants** that the subdivision may be known by, either locally or globally. For each local/other name, the **ISO 639** 3 letter language code is used to identify the language of the name. Some translations do not have available ISO 639 codes, therefore the |glottolog_link| or other databases (e.g |ietf_link|) language codes are used. Some example local/other name entries are: * **Sindh (Pakistan PK-SD)** - "سِنْدھ (urd), Sindh (eng), SD (eng), Mehran/Gateway (eng), Bab-ul-Islam/Gateway of Islam (eng)" * **Central Singapore (Singapore SG-01)** - "Pusat Singapura (msa), 新加坡中部 (zho), மத்திய சிங்கப்பூர் (tam)" * **Bobonaro (East Timor TL-BO)** - "Bobonaru (tet), Buburnaru (tet), Tall eucalypt (eng)" * **Wyoming (USA US-WY)** - "Equality State (eng), Cowboy State (eng), Big Wyoming (eng)" The full dataset of local/other names is available in the repo here |local_other_names_link|. Flags ~~~~~ The other equally important and bespoke/unique attribute that the software package supports is the ``flag`` attribute, which is a link to the subdivision's flag on the |iso3166_flag_icons_repo_link| repo. This is another **custom-built** repository, (alongside |iso3166_2_repo_link| and |iso3166_updates_repo_link|) that stores a rich and comprehensive dataset of over **2800** official individual subdivision flags, alongside ~250 ISO 3166-1 country/territory flags. The flags repo uses the |iso3166_2_repo_link| software to get the full list of ISO 3166-2 subdivision codes which is kept up-to-date and accurate via the |iso3166_updates_repo_link| software. .. raw:: html