Income Tax Calculator API - Ruby Gem

Income Tax Calculator is a tool for calculating US federal income tax. It takes your income, filing status, and year to compute your total tax, effective rate, marginal rate, and a full bracket-by-bracket breakdown.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_incometaxcalculator'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_incometaxcalculator

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_incometaxcalculator'

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

# Make a request
response = client.execute({
  income: 85000,
  rate: 22,
  deduction: 14600
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ income: 85000, rate: 22, deduction: 14600 })
  puts response["data"]
rescue APIVerve::Incometaxcalculator::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Incometaxcalculator::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

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

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "year": 2025,
    "filing_status": "single",
    "income": 85000,
    "standardDeduction": 15000,
    "taxableIncome": 70000,
    "totalTax": 10852.5,
    "effectiveRate": "12.77%",
    "marginalRate": "22%",
    "incomeAfterTax": 74147.5,
    "monthlyTax": 904.38,
    "monthlyIncome": 6178.96,
    "brackets": [
      {
        "rate": 0.1,
        "ratePercent": "10.0%",
        "rangeMin": 0,
        "rangeMax": 11925,
        "taxableAmount": 11926,
        "taxAmount": 1192.6
      },
      {
        "rate": 0.12,
        "ratePercent": "12.0%",
        "rangeMin": 11926,
        "rangeMax": 48475,
        "taxableAmount": 36550,
        "taxAmount": 4386
      },
      {
        "rate": 0.22,
        "ratePercent": "22.0%",
        "rangeMin": 48476,
        "rangeMax": 103350,
        "taxableAmount": 21524,
        "taxAmount": 4735.28
      }
    ]
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.