Cost of Living API - Ruby Gem
Cost of Living provides cost of living indices for US regions based on major metropolitan area data. Compare the relative cost of living between states, cities, or regions and calculate salary equivalents for relocation decisions.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_costliving'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_costliving
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_costliving'
# Initialize the client
client = APIVerve::Costliving::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ location: "California" })
# Print the response
puts response
Error Handling
begin
response = client.execute({ location: "California" })
puts response["data"]
rescue APIVerve::Costliving::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Costliving::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Costliving::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"from": {
"searchedLocation": "California",
"region": "west-large",
"regionName": "West Large Metros (LA, SF, Seattle, Phoenix, Denver area)",
"costIndex": 118
},
"to": {
"searchedLocation": "Texas",
"region": "south-large",
"regionName": "South Large Metros (Dallas, Houston, Atlanta, Miami, DC area)",
"costIndex": 103
},
"comparison": {
"costDifference": -12.7,
"direction": "less expensive",
"salaryEquivalent": {
"description": "A $100,000 salary in California is equivalent to $87,288 in Texas",
"fromSalary": 100000,
"equivalentSalary": 87288
}
}
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/costliving?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.