No commit activity in last 3 years
No release in over 3 years
Provides a client for the Oanda Exchange Rate API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.8
~> 10.0
>= 0
~> 0.9.1
~> 2.9.3
~> 1.20.4

Runtime

 Project Readme

Oanda Ruby Client

The Oanda Ruby Client provides a simple client class to retrieve exchange rates from Oanda using the Exchange Rate API.

Installation

Add this line to your application's Gemfile:

gem 'oanda_ruby_client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install oanda_ruby_client

Usage

Getting Started

Initialize the client as follows:

require 'oanda_ruby_client'

client = OandaRubyClient::ExchangeRatesClient.new('MY_API_KEY') # Provide your API Key as the parameter

If you store the API key in an environment variable named OANDA_RUBY_CLIENT_API_KEY, you can omit the parameter:

client = OandaRubyClient::ExchangeRatesClient.new

Get Rates

Create a request specifying the base currency as the first parameter, and any optional paramters as a hash. The keys of the optional paramters are the same as those for the Exchange Rate API:

For example, to specify a base currency of USD, a quote currency of GBP, and a date of February 11, 2015:

rates_request = OandaRubyClient::RatesRequest.new('USD', quote: 'GBP', date: '2015-02-11')

Date parameters can be specified using a string in the format of YYYY-MM-DD or by using an instance of Date:

require 'date'

rates_request = OandaRubyClient::RatesRequest.new('USD', quote: 'GBP', date: Date.new(2015, 2, 11))

Multi-value parameters (e.g., quote currency) can be specified using arrays:

rates_request = OandaRubyClient::RatesRequest.new('USD', quote: [ 'GBP', 'EUR' ], date: '2015-02-11')

Pass the rates request as a parameter into the rates method of the client:

rates_result = client.rates(rates_request)

The returning object will be an OpenStruct with the attributes base_currency (String), meta (Hash), quotes (Hash).

Get Currencies

To obtain the collection of supported currencies, use the currencies method:

currencies_result = client.currencies

The returning object will be a hash of currency codes to descriptions.

Get Remaining Quotes

For plans that have a limited number of quotes, use the remaining_quotes method to return the number of remaining quotes:

remaining_quotes_result = client.remaining_quotes

Additional Resources

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 a new Pull Request