Skip to content

Commit 27e63b1

Browse files
committed
v1.8.2; refer to CHANGELOG.md for full list of dataset updates and software/feature changes.
1 parent 2ba5d27 commit 27e63b1

8 files changed

Lines changed: 94 additions & 108 deletions

File tree

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
alt="globe"
2424
style="height:220px; width:auto; max-width:calc(50% - 6px); object-fit:contain;" />
2525
<img
26-
src="https://raw.githubusercontent.com/amckenna41/iso3166-2/master/main/iso3166-2-logo.png"
26+
src="https://raw.githubusercontent.com/amckenna41/iso3166-2/refs/heads/main/iso3166-2-logo.png"
2727
alt="icon"
2828
style="height:220px; width:auto; max-width:calc(50% - 6px); object-fit:contain;" />
2929
</div>
@@ -105,10 +105,10 @@ For each local/other name, the ISO 639 3 letter language code is used to identif
105105
* **Bobonaro (East Timor TL-BO)**: "Bobonaru (tet), Buburnaru (tet), Tall eucalypt (eng)"
106106
* **Wyoming (USA US-WY)** - "Equality State (eng), Cowboy State (eng), Big Wyoming (eng)"
107107

108-
The full dataset of local/other names is available in the repo here [`local_other_names.csv`](https://github.com/amckenna41/iso3166-2/iso3166_2_resources/local_other_names.csv)
108+
The full dataset of local/other names is available in the repo here [`local_other_names.csv`](https://github.com/amckenna41/iso3166-2/blob/main/iso3166_2_resources/local_other_names.csv)
109109

110110

111-
### Flags
111+
### Flags
112112
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-flags`](https://github.com/amckenna41/iso3166-flags) repo. This is another **custom-built** repository, (alongside [`iso3166-2`](https://github.com/amckenna41/iso3166-2) and [`iso3166-updates`](https://github.com/amckenna41/iso3166-updates)) that stores a rich and comprehensive dataset of over **3500** individual subdivision flags.
113113

114114
The flags repo uses the `iso3166-2` software to get the full list of ISO 3166-2 subdivision codes which is kept up-to-date and accurate via the `iso3166-updates` software.
@@ -132,6 +132,8 @@ Two additional bespoke attributes that have been recently added to the software
132132
* [natsort][natsort] >= 8.4.0
133133
* [thefuzz][thefuzz] >= 0.22.1
134134
* [requests][requests] >= 2.28.1
135+
* [pycountry][pycountry] >= 24.6.1
136+
135137
<!-- * [unidecode][unidecode] >= 1.3.8 -->
136138

137139
## Installation
@@ -199,10 +201,11 @@ all default attributes.
199201
'''
200202
from iso3166_2 import *
201203

202-
#create instance of Subdivisions class
204+
#create instance of Subdivisions class - only getting flag, parent code and type attributes
203205
iso = Subdivisions(filter_attributes="flag,parentCode,type")
204206
```
205207

208+
********
206209
**Get list of subdivision codes for all or a subset of countries:**
207210
```python
208211
'''
@@ -340,7 +343,7 @@ An important thing to note about the ISO 3166-2 and its subdivision codes/names
340343

341344
The [`iso3166-updates`](https://github.com/amckenna41/iso3166-updates) repo is another open-source software package and accompanying RESTful API that pulls the latest updates and changes for any and all countries in the ISO 3166 from a variety of data sources including the ISO website itself. A script is called periodically to check for any updates/changes to the subdivisions, which are communicated via the ISO's Online Browsing Platform [[4]](#references), and will then be manually incorporated into this repo. Please visit the repository home page for more info about the purpose and process of the software and API - [`iso3166-updates`](https://github.com/amckenna41/iso3166-updates).
342345

343-
The list of ISO 3166 updates was last updated on <strong>November 2024</strong> (the last published ISO subdivision change). A log of the latest ISO 3166 updates can be seen in the [UPDATES.md][updates_md] file.
346+
The list of ISO 3166 updates was last updated on <strong>July 2025</strong> (the last published ISO subdivision change). A log of the latest ISO 3166 updates can be seen in the [UPDATES.md][updates_md] file.
344347

345348
## API
346349
The main API endpoint is:
@@ -405,7 +408,7 @@ having a lower value will return less exact but more total matches, e.g ``/api/s
405408
<!-- ## ISO 3166-2 Scripts
406409
* [`scripts/main.py`](https://github.com/amckenna41/iso3166-2/blob/main/scripts) - used for pulling and exporting the latest ISO 3166-2 data from the various data sources. In this script you can also export additional attributes for each country/subdivision via the RestCountries and CountryStateCity APIs.
407410
* [`scripts/update_subdivisions.py`](https://github.com/amckenna41/iso3166-2/blob/main/scripts) - used for adding, amending and or deleting subdivisions to the `iso3166-2` software and object.
408-
* [`scripts/local_other_names.py`](https://github.com/amckenna41/iso3166-2/blob/main/scripts/local_other_names.py) - used for adding the data from the local_other_names.csv dataset, including any validation checks on the data.
411+
* [`scripts/local_other_names.py`](https://github.com/amckenna41/iso3166-2/blob/main/iso3166_2_resources/local_other_names.csv) - used for adding the data from the local_other_names.csv dataset, including any validation checks on the data.
409412
* [`scripts/utils.py`](https://github.com/amckenna41/iso3166-2/blob/main/scripts/utils.py) - a series of utility functions used throughout the `iso3166-2` project.
410413
* [`scripts/language_lookup.py`](https://github.com/amckenna41/iso3166-2/blob/main/scripts/language_lookup.py) - uses the `local_other_names.csv` dataset to encapsulate and validate the hundreds of language code used throughout the dataset and project.
411414

UPDATES.md

Lines changed: 0 additions & 77 deletions
This file was deleted.

docs/api.rst

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ The other endpoints available in the API are:
2121
* https://iso3166-2-api.vercel.app/api/country_name/<input_country_name>
2222
* https://iso3166-2-api.vercel.app/api/search/<input_search>
2323
* https://iso3166-2-api.vercel.app/api/search_geo/<input_search>
24-
* https://iso3166-2-api.vercel.app/api/search_latlng/<input_latlng>
2524
* https://iso3166-2-api.vercel.app/api/list_subdivisions/<input_alpha>
2625

2726
.. Six paths/endpoints are available in the API - `/api/all`, `/api/alpha`, `/api/country_name`, `/api/subdivision`, `/api/search` and `/api/list_subdivisions`.
@@ -38,8 +37,6 @@ The other endpoints available in the API are:
3837
3938
.. * `/api/search_geo/`: search for subdivisions and return only geographic attributes (e.g. latLng, bounding box, geojson, neighbours, perimeter) for 1 or more input search terms. Accepts comma separated subdivision names or ISO 3166-2 subdivision codes, e.g `/api/search_geo/Saarland,US-CA`. Supports the `likeness` query string parameter to control match tolerance.
4039
41-
.. * `/api/search_latlng/`: search for subdivisions via their latLng values. Accepts a comma separated string of latitude and longitude (e.g. `/api/search_latlng/39.4178,-2.6232`). Matches are approximate (not necessarily exact) based on closeness to the input coordinates.
42-
4340
.. * `/api/list_subdivisions`: get list of all the subdivision codes for all countries.
4441
4542
.. * `/api`: main homepage and API documentation.
@@ -280,11 +277,11 @@ curl::
280277
$ curl -i https://iso3166-2-api.vercel.app/api/search/Northern?likeness=80
281278
282279
283-
Search for a subdivision by lat/lon
284-
-----------------------------------
285-
This endpoint allows you to search for a specific ISO 3166-2 subdivision via its lat/lon values in the latLng
286-
attribute of the returned objects. Input should be a comma separated latitude/longitude string. The search is
287-
approximate, not necessarily an exact match.
280+
Search for subdivision geography
281+
--------------------------------
282+
This endpoint allows you to search for a specific ISO 3166-2 subdivision and return only geographic attributes
283+
(latLng, boundingBox, geojson, neighbours, perimeter). Input can be a comma separated list of subdivision
284+
names or ISO 3166-2 subdivision codes. The search is approximate based on the likeness score.
288285
289286
Python Requests:
290287
@@ -293,20 +290,15 @@ Python Requests:
293290
import requests
294291
295292
base_url = "https://iso3166-2-api.vercel.app/api/"
296-
input_latlng = "39.4178,-2.6232"
297-
data = requests.get(f'{base_url}/search_latlng/{input_latlng}').json()
298-
299-
data["ES-CM"] # Castilla-La Mancha
300-
301-
input_latlng = "-12.5,-72.5"
302-
data = requests.get(f'{base_url}/search_latlng/{input_latlng}').json()
293+
input_search = "Saarland,US-CA"
294+
data = requests.get(f'{base_url}/search_geo/{input_search}').json()
303295
304-
data["PE-CUS"] # Cusco
296+
data["DE-SL"] # Saarland
297+
data["US-CA"] # California
305298
306299
curl::
307300
308-
$ curl -i https://iso3166-2-api.vercel.app/api/search_latlng/39.4178,-2.6232
309-
$ curl -i https://iso3166-2-api.vercel.app/api/search_latlng/-12.5,-72.5
301+
$ curl -i https://iso3166-2-api.vercel.app/api/search_geo/Saarland,US-CA
310302
311303
312304
Get list of all subdivision codes per country

0 commit comments

Comments
 (0)