Unemployment Rate API - Ruby Gem
Unemployment Rate is a tool for retrieving unemployment statistics by country. It returns the unemployment rate as a percentage of the total labor force, with data available for over 200 countries from 1991 to present.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_unemployment'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_unemployment
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_unemployment'
# Initialize the client
client = APIVerve::Unemployment::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
country: "USA",
year: 2023
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ country: "USA", year: 2023 })
puts response["data"]
rescue APIVerve::Unemployment::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Unemployment::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Unemployment::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"country": "USA",
"countryName": "United States",
"year": 2024,
"count": 1,
"historical": [
{
"year": 2024,
"rate": 4.02
}
]
},
"code": 200
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/unemployment?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.