Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidesantangelo/restcountry
This is a Ruby wrapper library around the API provided by REST Countries http://restcountries.eu
https://github.com/davidesantangelo/restcountry
rest-countries ruby rubygem
Last synced: about 2 months ago
JSON representation
This is a Ruby wrapper library around the API provided by REST Countries http://restcountries.eu
- Host: GitHub
- URL: https://github.com/davidesantangelo/restcountry
- Owner: davidesantangelo
- License: mit
- Created: 2015-04-08T16:05:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-03-22T11:21:48.000Z (almost 4 years ago)
- Last Synced: 2024-10-31T13:30:49.902Z (2 months ago)
- Topics: rest-countries, ruby, rubygem
- Language: Ruby
- Homepage:
- Size: 125 KB
- Stars: 36
- Watchers: 5
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Restcountry
This is a [RubyGem](https://rubygems.org/gems/restcountry) wrapper library around the API provided by
[Restcountries](https://restcountries.eu).## Installation
Add this line to your application's Gemfile:
```ruby
gem 'restcountry'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install restcountry
## Usage
```ruby
require 'restcountry'# Find all countries
countries = Restcountry::Country.all# Find a country by name
country = Restcountry::Country.find_by_name('italy')# Access the country's attributes
country.capital
#=> Romecountry.region
#=> Europecountry.callingCodes
#=> "39"# Find a country by capital
country = Restcountry::Country.find_by_capital('Rome')country.name
#=> Italycountries = Restcountry::Country.find_by_lang('it')
countries.first
#=> Holy See```
## Attributesname,
capital,
altSpellings,
relevance,
region,
subregion,
translations,
population,
latlng,
demonym,
area,
gini,
timezones,
borders,
nativeName,
callingCodes,
topLevelDomain,
alpha2Code,
alpha3Code,
currencies,
languages## Credits
Many thanks to Fayder Florez for his implementation of the API.## Contributors
All Contributors## Related projects
[gocountries](https://github.com/alediaferia/gocountries).
## License
The restcountry GEM is released under the MIT License.