Mortgage Calculator API - Ruby Gem
Mortgage Calculator is a simple tool for calculating mortgage payments. It returns the monthly payment, total interest, and more.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_mortgagecalculator'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_mortgagecalculator
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_mortgagecalculator'
# Initialize the client
client = APIVerve::Mortgagecalculator::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
amount: 570000,
rate: 6.8,
years: 30
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ amount: 570000, rate: 6.8, years: 30 })
puts response["data"]
rescue APIVerve::Mortgagecalculator::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Mortgagecalculator::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Mortgagecalculator::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"amount": 570000,
"downpayment": 0,
"rate": 6.8,
"years": 30,
"total_interest_paid": 767750.49,
"total_loan_payment": 1337750.49,
"interestRatio": 57.39,
"monthly_payment": {
"total": 3715.97,
"mortgage": 3715.97,
"property_tax": 0,
"hoa": 0,
"home_insurance": 0
},
"annual_payment": {
"total": 44591.68,
"mortgage": 44591.68,
"property_tax": 0,
"hoa": 0,
"home_insurance": 0
},
"formatted": {
"amount": "$570,000",
"monthlyPayment": "$3,715.97",
"totalInterestPaid": "$767,750.49",
"totalLoanPayment": "$1,337,750.49"
},
"amortization_schedule": [
{
"month": 1,
"interest_payment": 3230,
"principal_payment": 485.97,
"remaining_balance": 569514.03
},
{
"month": 2,
"interest_payment": 3227.25,
"principal_payment": 488.73,
"remaining_balance": 569025.3
},
{
"month": 3,
"interest_payment": 3224.48,
"principal_payment": 491.5,
"remaining_balance": 568533.8
}
]
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://mortgagecalculator.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.