RestcountriesEx v0.1.0 RestcountriesEx.Country View Source

Link to this section Summary

Functions

Returns all the countries from the Rest Countries API as a list of maps

Searches for countries by calling code. This returns a list of countries, and uses the /callingcode/{calling_code} endpoint

Searches for countries by capital city, can accept full name or partial name. This returns a list of countries, and uses the /capital/{city_name} endpoint

Searches a country by country code, ISO 3166-1 2-letter or 3-letter country. This returns a list of countries, and uses the /alpha?codes={code} endpoint

Searches a country by currency code, ISO 4217 curreny code. This returns a list of countries, and uses the /currency/{currency_code} endpoint

Searches a country by language code, ISO 6391_1 2-letter or ISO 6391_2 3-letter language code. This returns a list of countries, and uses the /currency/{currency_code} endpoint

Searches a country by name. The full_text option dicates whether the search will be strict

Searches for countries by region — Africa, Americas, Asia, Europe, Oceania. This returns a list of countries, and uses the /region/{region_name} endpoint

Link to this section Functions

Returns all the countries from the Rest Countries API as a list of maps.

Examples

iex> RestcountriesEx.Country.all()
{:ok, [%{}, ...]}
Link to this function find_by_calling_code(calling_code) View Source

Searches for countries by calling code. This returns a list of countries, and uses the /callingcode/{calling_code} endpoint.

Examples

iex> RestcountriesEx.Country.find_by_calling_code(63)
{:ok, [%{alpha2Code: "PH"}]}
Link to this function find_by_capital_city(city_name) View Source

Searches for countries by capital city, can accept full name or partial name. This returns a list of countries, and uses the /capital/{city_name} endpoint.

Examples

iex> RestcountriesEx.Country.find_by_capital_city("manila")
{:ok, [%{alpha2Code: "PH"}]}

iex> RestcountriesEx.Country.find_by_capital_city("man")
{:ok, [%{alpha2Code: "PH", ...}]}
Link to this function find_by_country_code(codes) View Source

Searches a country by country code, ISO 3166-1 2-letter or 3-letter country. This returns a list of countries, and uses the /alpha?codes={code} endpoint.

Examples

iex> RestcountriesEx.Country.find_by_country_code(["co"])
{:ok, [%{alpha2Code: "co"}]}

iex> RestcountriesEx.Country.find_by_country_code(["co", "us", um")
{:ok, [%{alpha2Code: "co"}]}
Link to this function find_by_currency_code(currency) View Source

Searches a country by currency code, ISO 4217 curreny code. This returns a list of countries, and uses the /currency/{currency_code} endpoint.

Examples

iex> RestcountriesEx.Country.find_by_currency_code("php")
{:ok, [%{alpha2Code: "PH"}]}
Link to this function find_by_language_code(language) View Source

Searches a country by language code, ISO 6391_1 2-letter or ISO 6391_2 3-letter language code. This returns a list of countries, and uses the /currency/{currency_code} endpoint.

Examples

iex> RestcountriesEx.Country.find_by_currency_code("en")
{:ok, [%{alpha2Code: "PH", ...}]}

iex> RestcountriesEx.Country.find_by_currency_code("eng")
{:ok, [%{alpha2Code: "PH", ...}]}
Link to this function find_by_name(name, full_text \\ false) View Source

Searches a country by name. The full_text option dicates whether the search will be strict.

Examples

iex> RestcountriesEx.Country.find_by_name("united states")
{:ok, [%{alpha2Code: "UM"}, %{alpha2Code: "US"}]}

iex> RestcountriesEx.Country.find_by_name("united states", true)
{:ok, [%{alpha2Code: "US"}]}

Searches for countries by region — Africa, Americas, Asia, Europe, Oceania. This returns a list of countries, and uses the /region/{region_name} endpoint.

Examples

iex> RestcountriesEx.Country.find_by_region("asia")
{:ok, [%{alpha2Code: "PH", ...}]}