diff --git a/.github/workflows/CHANGELOG.md b/.github/workflows/CHANGELOG.md index 61120ad..71d0030 100644 --- a/.github/workflows/CHANGELOG.md +++ b/.github/workflows/CHANGELOG.md @@ -8,15 +8,18 @@ ## v1.6.1 - June 2024 + ### Added - list_subdivisions endpoint added to API that returns list of all subdivision codes per country - Unit tests for flag_url function in update_subdivisions script - Separate function for extracting and parsing data attributes from RestCountries API - Added raise_for_status error catcher for requests library + ### Changed - Rotate user agent headers for any scripts using requests.get + ### Fixed - Error in request URL for RestCountries API in update_subdivisions script - Raise TypeError if invalid data type input to export_iso3166_2 function rather than system crashing diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index d70fdd0..3d71102 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -43,6 +43,8 @@ jobs: #unit tests using unittest framework - name: Running unit tests + env: + GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }} run: | echo "Testing using unittest..." python3 -m unittest discover tests -v @@ -154,8 +156,9 @@ jobs: #generate codecov report using pytest - name: Generate Coverage report - run: | - pytest --cov tests/ + env: + GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }} + run: pytest --cov tests/ #upload to Code Coverage, only if matrix python version is 3.10 - name: Upload Coverage Report to Codecov diff --git a/API.md b/API.md index d47e644..22260cc 100644 --- a/API.md +++ b/API.md @@ -13,6 +13,7 @@ The other endpoints available in the API are: * https://iso3166-2-api.vercel.app/api/country_name/ * https://iso3166-2-api.vercel.app/api/subdivision/ * https://iso3166-2-api.vercel.app/api/name/ +* https://iso3166-2-api.vercel.app/api/list_subdivisions Six paths/endpoints are available in the API - `/api/all`, `/api/alpha`, `/api/country_name`, `/api/subdivision`, `/api/name` and `/api/list_subdivisions`. diff --git a/README.md b/README.md index b2135c0..ffcfd88 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Table of Contents - [Installation](#installation) - [Usage](#usage) - [Documentation](#documentation) -- [Usage](#usage-iso3166_2_scriptsupdate_subdivisionspy) +- [Usage](#usage) - [Directories](#directories) - [Issues or Contributing](#issues-or-contributing) - [Contact](#contact) @@ -85,7 +85,7 @@ The other endpoints available in the API are: * https://iso3166-2-api.vercel.app/api/subdivision/ * https://iso3166-2-api.vercel.app/api/name/ -Five paths/endpoints are available in the API - `/api/all`, `/api/alpha`, `/api/country_name`, `/api/subdivision` and `/api/name`. +Six paths/endpoints are available in the API - `/api/all`, `/api/alpha`, `/api/country_name`, `/api/subdivision`, `/api/name` and `/api/list_subdivisions`. * `/api/all`: get all of the ISO 3166 subdivision data for all countries. @@ -97,6 +97,8 @@ Five paths/endpoints are available in the API - `/api/all`, `/api/alpha`, `/api/ * `/api/name/`: get all of the ISO 3166 subdivision data for 1 or more ISO 3166-2 subdivision names, e.g `/api/name/Derry`. You can also input a comma separated list of subdivision name from the same or different countries and the data for each will be returned e.g `/api/name/Paris,Frankfurt,Rimini`. A closeness function is utilised to find the matching subdivision name, if no exact name match found then the most approximate subdivisions will be returned. Some subdivisions may have the same name, in this case each subdivision and its data will be returned e.g `/api/name/Saint George` (this example returns 5 subdivisions). This endpoint also has the likeness score (`?likeness=`) query string parameter that can be appended to the URL. This can be set between 1 - 100, representing a % of likeness to the input name the return subdivisions should be, e.g: a likeness score of 90 will return fewer potential matches whose name only match to a high degree compared to a score of 10 which will create a larger search space, thus returning more potential subdivision matches. A default likeness of 100 (exact match) is used, if no matching subdivision is found then this is reduced to 90. If an invalid subdivision name that doesn't match any is input then an error will be raised. +* `/api/list_subdivisions`: get list of all the subdivision codes for all countries. + * `/api`: main homepage and API documentation. The API documentation and usage with all useful commands and examples to the API is available on the [API.md][api_md] file. A demo of the software and API is available [here][demo]. @@ -228,7 +230,7 @@ Documentation for installation and usage of the software and API is available on ISO 3166-2 Scripts ------------------ -* The [`iso3166_2_scripts/get_iso3166_2.py`](https://github.com/amckenna41/iso3166-2/blob/main/iso3166_2_scripts) script is used for pulling and exporting the latest ISO 3166-2 data from the various data sources +* The [`iso3166_2_scripts/get_iso3166_2.py`](https://github.com/amckenna41/iso3166-2/blob/main/iso3166_2_scripts) script is 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 API. * The [`iso3166_2_scripts/update_subdivisions.py`](https://github.com/amckenna41/iso3166-2/blob/main/iso3166_2_scripts) script is used for adding, amending and or deleting subdivisions to the `iso3166-2` software and object. Please visit the [README](https://github.com/amckenna41/iso3166-2/blob/main/iso3166_2_scripts) of the `iso3166_2_scripts` folder for more in depth info about the usage and requirements of the above two scripts vital to the `iso3166-2` software. diff --git a/docs/api.rst b/docs/api.rst index 6fff9bc..6f71919 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -19,7 +19,7 @@ The other endpoints available in the API are: * https://iso3166-2-api.vercel.app/api/name/ * https://iso3166-2-api.vercel.app/api/list_subdivisions -Five paths/endpoints are available in the API - `/api/all`, `/api/alpha`, `/api/subdivision`, `/api/country_name`, `/api/name` and `/api/list_subdivisions`. +Six paths/endpoints are available in the API - `/api/all`, `/api/alpha`, `/api/subdivision`, `/api/country_name`, `/api/name` and `/api/list_subdivisions`. * `/api/all`: get all of the ISO 3166 subdivision data for all countries. @@ -221,12 +221,6 @@ curl:: $ curl -i https://iso3166-2-api.vercel.app/api/name/Northern?likeness=0.8 $ curl -i https://iso3166-2-api.vercel.app/api/name/Southern?likeness=0.8 -.. note:: - A demo of the software and API is available |demo_link|. - -.. |demo_link| raw:: html - - here Get list of all subdivision codes per country --------------------------------------------- @@ -247,4 +241,12 @@ Python Requests: curl:: - $ curl -i https://iso3166-2-api.vercel.app/api/list_subdivisions \ No newline at end of file + $ curl -i https://iso3166-2-api.vercel.app/api/list_subdivisions + + +.. note:: + A demo of the software and API is available |demo_link|. + +.. |demo_link| raw:: html + + here \ No newline at end of file diff --git a/iso3166_2_scripts/README.md b/iso3166_2_scripts/README.md index 02b9c8e..f55d0c8 100644 --- a/iso3166_2_scripts/README.md +++ b/iso3166_2_scripts/README.md @@ -119,6 +119,8 @@ python3 iso3166_2_scripts/update_subdivisions.py --alpha_code=FR --subdivision_c python3 iso3166_2_scripts/update_subdivisions.py --subdivision_csv=new_subdivisions.csv ``` +[Back to top](#TOP) + [python]: https://www.python.org/downloads/release/python-360/ [requests]: https://requests.readthedocs.io/