Exchange Rate API - Ruby Gem
Exchange Rate is a simple tool for getting the current exchange rate between two currencies. It returns the current exchange rate.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_exchangerate'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_exchangerate
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_exchangerate'
# Initialize the client
client = APIVerve::Exchangerate::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
currency1: "USD",
currency2: "EUR"
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ currency1: "USD", currency2: "EUR" })
puts response["data"]
rescue APIVerve::Exchangerate::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Exchangerate::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Exchangerate::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"currency1": "USD",
"currency2": "EUR",
"exchangeRate": "0.851223",
"inverseRate": "1.174773"
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://exchangerate.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.