Hi everyone!
I needed some geographical data and started out with the Countries library. But I realized I needed some data that Countries doesn’t provide, so I started looking for other datasets.
I found the countries-states-cities-database project, which seems pretty well-maintained and the data it provides seems complete.
After building an integration for the dataset, I figured I might as well open source it.
Examples
Get a country:
iex> Place.get_country(country_code: "US")
%Place.Country{
capital: "Washington",
csc_id: 233,
csc_region_id: "2",
csc_subregion_id: "6",
currency: "USD",
currency_name: "United States dollar",
currency_symbol: "$",
emoji: "🇺🇸",
emojiU: "U+1F1FA U+1F1F8",
iso2: "US",
iso3: "USA",
latitude: "38.00000000",
longitude: "-97.00000000",
name: "United States",
nationality: "American",
native: "United States",
numeric_code: "840",
phone_code: "1",
... # and more
}
Get all countries:
iex> Place.get_countries() |> Enum.count()
250
Get all cities in a state:
iex> Place.get_cities(country_code: "US", state_code: "CA") |> Enum.count()
1124
See the Place
module for the rest of the API.