Skip to content

exchangerateapinet/exchangerateapi-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exchangerateapi-ruby

Gem Version Downloads GitHub release License: MIT

Small Ruby client for exchangerateapi.net with straightforward methods and no external dependencies.

Installation

gem install exchangerateapinet

Quick start

require "exchangerateapi/client"
client = Exchangerateapi::Client.new(api_key: "YOUR_API_KEY")

Usage patterns

  • Get the newest rates for a base currency; optionally select specific symbols.
  • Look up historical rates for a given date and base.

Configure

You can tweak the base URL and provide your own HTTP timeouts by wrapping calls in Net::HTTP.start or using a proxy. The client constructs a query-string request and parses JSON.

Latest

client.latest(base: "USD")
client.latest(base: "EUR", symbols: ["USD", "GBP", "JPY"])

Historical

client.historical(date: "2024-01-02", base: "USD")
client.historical(date: "2024-01-02", base: "EUR", symbols: ["USD", "GBP", "JPY"])

Error handling

When the API returns an error payload, the client raises StandardError with a short message. Wrap calls with begin/rescue to surface user-friendly messages or to retry.

begin
  client.latest(base: "XYZ") # invalid base
rescue => e
  warn "request failed: #{e.message}"
end

Run the examples

EXCHANGERATEAPI_KEY=your_api_key ruby examples/latest.rb
EXCHANGERATEAPI_KEY=your_api_key ruby examples/historical.rb

Free usage

A free tier is available for testing and light workloads. It uses an API key and includes basic access to the latest and historical endpoints with rate limits. Refer to the latest details on exchangerateapi.net.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages