No release in over 3 years
Low commit activity in last 3 years
A Simple and Rich for Exchange Rates
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 10.0
~> 3.0

Runtime

~> 6.0, >= 6.0.2.1
~> 1.0
 Project Readme

Vici::ExchangeRates

A Simple and Rich for Exchange Rates

CI Gem Version GitHub license

Vici::ExchangeRates is an unofficial SDK for the ExchangeRatesAPI. Exchange rates API is a free service for current and historical foreign exchange rates published by the European Central Bank.

Libur.run - Empower Your HR with Next-Gen Open Source Self-Serve Platform

Note

  • This app requires JSON. If you're using JRuby < 1.7.0 you'll need to add gem "json" to your Gemfile or similar.

Installation

Add this line to your application's Gemfile:

gem 'vici-exchange-rates'

And then execute:

$ bundle

Or install it yourself as:

$ gem install vici-exchange-rates

Usage

Currency code must be one of the supported currency codes.

Basic usage

require 'vici/exchange_rates'

rates = Vici::ExchangeRates.new
# or you can retrieve JSON response
rates = Vici::ExchangeRates.new(true) 
rates.fetch

Historical rates for any day since 1999

rates.at_date('2018-02-02')
rates.fetch
# OR
rates.at_date('2018-02-02').fetch 

Latest exchange rates with different base currency (Euro by default)

rates.base_currency('IDR')
rates.fetch 

Specific exchange rates

rates.rates('IDR')

# multi exchange rates
rates.rates(['IDR', 'USD']) 
rates.fetch 
# => {"rates"=>{"USD"=>1.1052, "IDR"=>15091.51}, "base"=>"EUR", "date"=>"2020-01-31"}

Historical rates for a time period

rates.period(date_from: '2018-01-03', date_to: '2018-02-05') 
rates.fetch 

Limit to specific exchange rates

rates.rates(['IDR', 'JPY']).period(date_from: '2018-01-03', date_to: '2018-02-05') 
rates.fetch 

Historical rates with different currency

rates.base_currency('JPY').period(date_from: '2018-01-03', date_to: '2018-02-05') 
rates.fetch

Supported Currencies

The library supports any currency currently available on the European Central Bank's web service, please refer to here.

Contributing

  1. Fork the repo
  2. Grab dependencies: bundle install
  3. Make sure everything is working: bundle exec rake spec
  4. Make your changes
  5. Test your changes
  6. Create a Pull Request
  7. Celebrate!!!!!

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Copyright

Copyright (c) 2020 Maful Prayoga A. See LICENSE for further details.