Isocodes
ISO codes for Nim. Supports loading the data at runtime or embedding it within the executable.
Install / Use
/learn @kraptor/IsocodesREADME
isocodes
ISO codes for Nim.
Supports loading the data at runtime or embedding it within the executable
Provides the utility isocodes_download to download latest JSON packages when
you don't want to use the provided ones (or if they become obsolete).
By default all data is embedded within the executable. See section Compilation flags on how to specify the files to load/embed and how to load the data at runtime if you need to.
Supported ISO standards
| ISO | Description | Library type |
|-|-|-|
| ISO 3166-1 | Name of countries | Country |
| ISO 3166-2 | Country subdivisions | CountrySubdivision|
| ISO 3166-3 | Countries removed from the standard. | RemovedCountry |
| ISO 15924 | Language scripts | Script |
| ISO 4217 | Currencies | Currency |
| ISO 639-2 | Languages | Language |
| ISO 639-5 | Language Families | LanguageFamily |
Example
import isocodes
if isMainModule:
for c in Country.allIt():
echo c.name
API
All procedures/iterators can be accessed by using the corresponding type.
For example: Country.
Procedures either return an Option[T] object or a seq[T] (when multiple
values can be requested).
IMPORTANT: Procedures ending in
Itreturn an iterator, instead of aseq[T], if you don't want to store/build a copy of the data requested.
Country API
Country Attributes
The following attributes are available for each Country instance:
| Attribute | Description |
|-|-|
|name | Country name. |
|official_name| Official name of the country. |
|common_name | Common name for the country. |
|alpha_2 | Country ISO code (2 characters).|
|alpha_3 | Country ISO code (3 characters).|
|numeric | Numeric code for the country. NOTE: this is a string. |
|flag | Flag emoji for the country. |
Country Procedures
| Procedure | Description |
|-|-|
|.count() | Number of countries |
|.all() | seq for all countries. |
|.allIt() | Iterator for all countries. |
|.byName(str) | Option[Country] with the specified name. |
|.byAlpha2(str) | Option[Country] with the specified alpha2 code. |
|.byAlpha3(str) | Option[Country] with the specified alpha3 code. |
|.byNumeric(str) | Option[Country] with the specified numeric code. |
|.byOfficialName(str)| Option[Country] with the specified official name. |
|.byCommonName(str) | Option[Country] with the specified common name. |
|.find(proc) | seq for all countries that proc evaluates to true. |
|.findIt(proc) | Iterator for all countries that proc evaluates to true.|
|.findFirst(proc) | Option[Country] were proc evaluates to true. |
CountrySubdivision API
CountrySubdivision Attributes
| Attribute | Description |
|-|-|
|code | Subdivision code. |
|name | Name of the subdivision. |
|type | Type of the subdivision.<br />NOTE: use stropping to access this field because type is a reserved word.<br />Example: echo subdivision.`type` .|
|parent | Parent code.|
CountrySubdivision Procedures
| Procedure | Description |
|-|-|
|.count() | Number of subdivisions |
|.all() | seq for all subdivisions. |
|.allIt() | Iterator for all subdivisions. |
|.byCountryCode(str) | seq for subdivisions for an specific country code. |
|.byCountryCodeIt(str)| Iterator for subdivisions for an specific country code. |
|.byCode(str) | seq for subdivisions by specified code. |
|.byCodeIt(str) | Iterator for subdivisions specified by code. |
|.byCodeStart(str) | seq for subdivisions where code starts by a value. |
|.byCodeStartIt(str) | Iterator subdivisions where code starts by a value. |
|.byName(str) | seq for subdivisions with specified name. |
|.byNameIt(str) | Iterator for subdivisions with specified name. |
|.byType(str) | seq for subdivisions with the specified type. |
|.byTypeIt(str) | Iterator for subdivisions with the specified type. |
|.byParent(str) | seq for subdivisions with the specified parent value. |
|.byParentIt(str) | Iterator for subdivisions with the specified parent value. |
|.find(proc) | seq for all subdivisions that proc evaluates to true. |
|.findIt(proc) | Iterator for all subdivisions that proc evaluates to true.|
|.findFirst(proc) | Option[CountrySubdivision] were proc evaluates to true. |
RemovedCountry API
RemovedCountry Attributes
| Attribute | Description |
|-|-|
|name | Country name. |
|official_name | Official name of the country. |
|alpha_2 | Country ISO code (2 characters). |
|alpha_3 | Country ISO code (3 characters). |
|alpha_4 | Country ISO code (4 characters). |
|numeric | Numeric code for the country. <br/> NOTE: this is a string.|
|comment | Comment about the country. |
|withdrawal_date| Date of withdrawal (format: YYYY or YYYY-MM-DD) <br/> NOTE: this is a string.|
RemovedCountry Procedures
| Procedure | Description |
|-|-|
|.count() | Number of countries |
|.all() | seq for all countries. |
|.allIt() | Iterator for all countries. |
|.byName(str) | Option[Country] with the specified name. |
|.byAlpha2(str) | Option[Country] with the specified alpha2 code. |
|.byAlpha3(str) | Option[Country] with the specified alpha3 code. |
|.byAlpha4(str) | Option[Country] with the specified alpha4 code. |
|.byNumeric(str) | Option[Country] with the specified numeric code. |
|.byWithdrawalDate(str) | seq for all countries with specified date. |
|.byWithdrawalDateIt(str)| Iterator all countries with specified date. |
|.byWithdrawalYear(str) | seq for all countries with specified year. |
|.byWithdrawalYearIt(str)| Iterator all countries with specified year. |
|.find(proc) | seq for all countries that proc evaluates to true. |
|.findIt(proc) | Iterator for all countries that proc evaluates to true.|
|.findFirst(proc) | Option[Country] were proc evaluates to true. |
Script API
Script Attributes
| Attribute | Description |
|-|-|
|name | Script name. |
|alpha_4 | Script ISO code (4 characters). |
|numeric | Numeric code for the script. <br/> NOTE: this is a string.|
Script Procedures
| Procedure | Description |
|-|-|
|.count() | Number of scripts |
|.all() | seq for all scripts. |
|.allIt() | Iterator for all scripts. |
|.byName(str) | Option[Script] with the specified name. |
|.byAlpha4(str) | Option[Script] with the specified alpha4 code. |
|.byNumeric(str) | Option[Script] with the specified numeric code. |
|.find(proc) | seq for all scripts that proc evaluates to true. |
|.findIt(proc) | Iterator for all scripts that proc evaluates to true. |
|.findFirst(proc)| Option[Script] were proc evaluates to true. |
Currency API
Currency Attributes
| Attribute | Description |
|-|-|
|name | Currency name. |
|alpha_3 | Currency ISO code (3 characters). |
|numeric | Numeric code for the currency. <br/> NOTE: this is a string.|
Currency Procedures
| Procedure | Description |
|-|-|
|.count() | Number of currencies. |
|.all() | seq for all currencies. |
|.allIt() | Iterator for all currencies. |
|.byName(str) | Option[Currency] with the specified name. |
|.byAlpha3(str) | Option[Currency] with the specified alpha3 code. |
|.byNumeric(str) | Option[Currency] with the specified numeric code. |
|.find(proc) | seq for all currencies that proc evaluates to true. |
|.findIt(proc) | Iterator for all currencies that proc evaluates to true.|
|.findFirst(proc)| Option[Currency] were proc evaluates to true. |
Language API
Language Attributes
| Attribute | Description |
|-|-|
|name | Language name. |
|alpha_2 | Language ISO code (2 characters). |
|alpha_3 | Language ISO code (3 characters). |
|common_name | Language common name. |
|bibliographic | Language biblio
Related Skills
openhue
339.3kControl Philips Hue lights and scenes via the OpenHue CLI.
sag
339.3kElevenLabs text-to-speech with mac-style say UX.
weather
339.3kGet current weather and forecasts via wttr.in or Open-Meteo
tweakcc
1.5kCustomize Claude Code's system prompts, create custom toolsets, input pattern highlighters, themes/thinking verbs/spinners, customize input box & user message styling, support AGENTS.md, unlock private/unreleased features, and much more. Supports both native/npm installs on all platforms.
