Purchasing Power API - Ruby Gem
Purchasing Power calculates the inflation-adjusted value of money between any two time periods. Find out what $100 from 1990 is worth today, or calculate real returns on investments accounting for inflation.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_purchasingpower'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_purchasingpower
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_purchasingpower'
# Initialize the client
client = APIVerve::Purchasingpower::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
amount: 100,
from: "1990",
to: "2024"
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ amount: 100, from: "1990", to: "2024" })
puts response["data"]
rescue APIVerve::Purchasingpower::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Purchasingpower::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Purchasingpower::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"originalAmount": 100,
"originalPeriod": "1990-01",
"adjustedAmount": 242.31,
"adjustedPeriod": "2024-01",
"cumulativeInflation": 142.31,
"multiplier": 2.423,
"explanation": "$100 in 1990-01 has the same purchasing power as $242.31 in 2024-01",
"fromCPI": 127.4,
"toCPI": 308.417
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/purchasingpower?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.