worldwide/country
Public country API.
Generated data lives in countries/internal/gen/country.gleam.
Regenerate it with gleam run -m worldwide/pull_countries.
Types
A Country record. Currencies and languages may be empty for some
territories. Codes follow ISO 3166-1.
pub type Country {
Country(
name: String,
alpha2: String,
alpha3: String,
numeric: String,
region: region.Region,
capital: option.Option(String),
currencies: List(currency.Currency),
languages: List(Language),
calling_codes: List(String),
timezones: List(duration.Duration),
)
}
Constructors
-
Country( name: String, alpha2: String, alpha3: String, numeric: String, region: region.Region, capital: option.Option(String), currencies: List(currency.Currency), languages: List(Language), calling_codes: List(String), timezones: List(duration.Duration), )Arguments
- name
-
Common English name, e.g. “Spain”.
- alpha2
-
ISO 3166-1 alpha-2 code, uppercase, e.g. “ES”.
- alpha3
-
ISO 3166-1 alpha-3 code, uppercase, e.g. “ESP”.
- numeric
-
ISO 3166-1 numeric code as a zero-padded string, e.g. “724”.
- region
-
Continental region.
- capital
-
Capital city, if the country has one.
- currencies
-
Currencies in use, primary first. May be empty.
- languages
-
Official / common languages. May be empty.
- calling_codes
-
International dialing prefixes, e.g. [“34”]. May be empty.
- timezones
-
Fixed UTC offsets used by the country. May be empty.
Values
pub fn from_alpha2(alpha2: String) -> Result(Country, Nil)
Look up a country by normalized alpha-2 code.
pub fn from_iso_code(code: String) -> Result(Country, Nil)
Look up a country by normalized alpha-2, alpha-3, or numeric code.
pub fn from_name(name: String) -> Result(Country, Nil)
Look up a country by exact common English name.
pub fn is_iso_code(code: String) -> Bool