A lightweight REST API that calculates loan payment metrics given amount, annual rate, and term in years. It returns monthly payment, total payment, and total interest using the standard amortization formula.
https://www.promptbox.cn/api/loan.php
GET and POST (JSON)
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
amount |
float | Yes | 200000 | Principal loan amount |
rate |
float | Yes | 5.5 | Annual interest rate in percent |
years |
integer | Yes | 30 | Term length in years |
{
"amount": 200000,
"rate": 5.5,
"years": 30
}
{
"monthlyPayment": 1135.58,
"totalPayment": 408808.80,
"totalInterest": 208808.80,
"inputs": {
"amount": 200000.00,
"rate": 5.50,
"years": 30.00
}
}
{
"error": "Missing or invalid 'amount'. Must be > 0."
}
GET /api/loan.php?amount=200000&rate=5.5&years=30
{
"monthlyPayment": 1135.58,
"totalPayment": 408808.80,
"totalInterest": 208808.80,
"inputs": {
"amount": 200000.00,
"rate": 5.50,
"years": 30.00
}
}
POST /api/loan.php
Content-Type: application/json
{
"amount": 200000,
"rate": 5.5,
"years": 30
}
{
"monthlyPayment": 1135.58,
"totalPayment": 408808.80,
"totalInterest": 208808.80,
"inputs": {
"amount": 200000.00,
"rate": 5.50,
"years": 30.00
}
}
GET /api/loan.php?amount=0&rate=5&years=30
{
"error": "Missing or invalid 'amount'. Must be > 0."
}
rate is annual percentage; internally converted to monthly decimal.GET and POST (JSON) are supported.