This is a tiny Elixir wrapper for the REST Countries API.
First, add Excountries to your mix.exs
dependencies:
def deps do
[{:excountries, "~> 0.0.1"}]
end
and run $ mix deps.get
.
There are multiple functions via which one can search for countries in the API.
Each function returns a single or a list of Country
structs.
Returns a list of countries.
Excountries.Radar.all()
Searches for a country by it's exact name:
Excountries.Radar.by_full_name("United States Of America")
Searches for a country by a substring of it's name or abbreviation:
Excountries.Radar.by_name("USA")
Searches for a country by a language code:
Excountries.Radar.by_language("en")
Language codes must be ISO 639-1 compliant. If not, throws error.
Searches for a country by currency name:
Excountries.Radar.by_currency("USD")
Searches for the country by it's capital city:
Excountries.Radar.by_capital("USD")
Searches for the country by it's calling code:
Excountries.Radar.by_calling_code("01")
Searches for the country by it's region:
Excountries.Radar.by_region("Oceania")
Searches for the country by it's subregion:
Excountries.Radar.by_subregion("Polynesia")
Searches for the country by it's country code:
Excountries.Radar.by_country_code("MKD")
%Excountries.Country
is a struct containing multiple properties:
- name
- capital
- relevance
- region
- subregion
- population
- latitude
- longitude
- demonym
- area
- timezones
- nativeName
- topLevelDomain
- currencies
- languages
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright © 2015 Ilija Eftimov [email protected]
This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE file for more details.