A Ruby Library for current and historical foreign exchange rates.
MIT License
A Simple and Rich for Exchange Rates
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
gem "json"
to your Gemfile or similar.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
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
The library supports any currency currently available on the European Central Bank's web service, please refer to here.
bundle install
bundle exec rake spec
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 (c) 2020 Maful Prayoga A. See LICENSE for further details.