Inflation Rate API - Ruby Gem
Inflation Rate is a tool for retrieving annual inflation rate and CPI data for countries worldwide. It returns the inflation rate, CPI index value, and country details for any year going back to 1960.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_inflation'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_inflation
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_inflation'
# Initialize the client
client = APIVerve::Inflation::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
country: "US",
year: 2023
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ country: "US", year: 2023 })
puts response["data"]
rescue APIVerve::Inflation::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Inflation::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Inflation::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"country": "US",
"countryName": "United States",
"year": 2023,
"inflationRate": 4.12,
"cpiIndex": 139.81,
"cpiBaseYear": 2010,
"lastUpdated": "2026-02-05T04:00:00.000Z"
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/inflation?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.