Age Calculator API - Ruby Gem
Age Calculator is a simple tool for calculating age from the date of birth. It returns the calculated age based on the date of birth provided.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_agecalculator'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_agecalculator
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_agecalculator'
# Initialize the client
client = APIVerve::Agecalculator::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ dob: "1990-08-02" })
# Print the response
puts response
Error Handling
begin
response = client.execute({ dob: "1990-08-02" })
puts response["data"]
rescue APIVerve::Agecalculator::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Agecalculator::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Agecalculator::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"dob": "1990-01-01",
"age_breakdown": {
"years": 35,
"months": 431,
"weeks": 1876,
"days": 13133,
"hours": 315208,
"minutes": 18912499,
"seconds": 1134749976
},
"age_words": {
"years": "thirty-five",
"ordinal": "thirty-fifth",
"full": "thirty-five years old",
"locale": "en-US"
},
"timezone": "America/Chicago",
"locale": "en-US",
"next_birthday": {
"months": 0,
"weeks": 2,
"days": 15,
"hours": 367,
"minutes": 22060,
"seconds": 1323623
},
"insights": {
"generation": "Millennial",
"zodiacSign": "Capricorn",
"chineseZodiac": "Horse",
"birthstone": "Garnet",
"dayOfWeekBorn": "Monday",
"isLeapYearBirth": false,
"milestones": {
"canVoteUS": true,
"canDrinkUS": true,
"canRentCarUS": true,
"seniorDiscount": false
}
}
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/agecalculator?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.