Currency Converter API - Ruby Gem
Currency Converter is a simple tool for converting currency rates. It returns the converted currency rate based on the amount and currency provided.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_currencyconverter'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_currencyconverter
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_currencyconverter'
# Initialize the client
client = APIVerve::Currencyconverter::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
value: 1,
from: "USD",
to: "EUR"
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ value: 1, from: "USD", to: "EUR" })
puts response["data"]
rescue APIVerve::Currencyconverter::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Currencyconverter::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Currencyconverter::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"from": "USD",
"to": "EUR",
"value": 1,
"convertedValue": 0.921456,
"rate": 0.921456,
"change24h": -0.002134,
"change24hPct": -0.2312,
"changeDirection": "down",
"high24h": 0.924521,
"low24h": 0.919823
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://currencyconverter.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.