Skip to content

pedromvieira/excountries

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Excountries

This is a tiny Elixir wrapper for the REST Countries API.

Installation

First, add Excountries to your mix.exs dependencies:

def deps do
  [{:excountries, "~> 0.0.1"}]
end

and run $ mix deps.get.

Usage

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.

Get all

Returns a list of countries.

 Excountries.Radar.all()

Name

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")

Language

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.

Currency

Searches for a country by currency name:

 Excountries.Radar.by_currency("USD")

Capital city

Searches for the country by it's capital city:

 Excountries.Radar.by_capital("USD")

Calling code

Searches for the country by it's calling code:

 Excountries.Radar.by_calling_code("01")

Region

Searches for the country by it's region:

 Excountries.Radar.by_region("Oceania")

Subregion

Searches for the country by it's subregion:

 Excountries.Radar.by_subregion("Polynesia")

Country code

Searches for the country by it's country code:

 Excountries.Radar.by_country_code("MKD")

Country

%Excountries.Country is a struct containing multiple properties:

  • name
  • capital
  • relevance
  • region
  • subregion
  • population
  • latitude
  • longitude
  • demonym
  • area
  • timezones
  • nativeName
  • topLevelDomain
  • currencies
  • languages

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Copyright © 2015 Ilija Eftimov ileeftimov@gmail.com

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.

About

Elixir wrapper for REST Countries API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%