Loan Calculator API - Ruby Gem

Loan Payment Calculator is a simple tool for calculating loan payments. It returns the monthly payment, total interest, and more.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_loanpaymentcalculator'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_loanpaymentcalculator

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_loanpaymentcalculator'

# Initialize the client
client = APIVerve::Loanpaymentcalculator::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({
  loanAmount: 32000,
  interestRate: 8.5,
  loanTerm: 6
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ loanAmount: 32000, interestRate: 8.5, loanTerm: 6 })
  puts response["data"]
rescue APIVerve::Loanpaymentcalculator::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Loanpaymentcalculator::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Loanpaymentcalculator::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "loanAmount": 32000,
    "downpayment": 0,
    "interestRate": 8.5,
    "loanTerm": 6,
    "monthly_payment": 568.91,
    "total_interest_paid": 8961.4,
    "total_payment": 40961.52,
    "interestRatio": 21.88,
    "formatted": {
      "loanAmount": "$32,000.00",
      "monthlyPayment": "$568.91",
      "totalInterestPaid": "$8,961.40",
      "totalPayment": "$40,961.52"
    },
    "amortization_schedule": [
      {
        "month": 1,
        "interest_payment": 226.67,
        "principal_payment": 342.24,
        "remaining_balance": 31657.76
      },
      {
        "month": 2,
        "interest_payment": 224.24,
        "principal_payment": 344.67,
        "remaining_balance": 31313.09
      },
      {
        "month": 3,
        "interest_payment": 221.8,
        "principal_payment": 347.11,
        "remaining_balance": 30965.99
      }
    ]
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.