Calculate Interest
curl --request POST \
--url https://api.magebank.ai/investment/calculator \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"amount": 123,
"days": 123,
"customRate": 123
}
'import requests
url = "https://api.magebank.ai/investment/calculator"
payload = {
"amount": 123,
"days": 123,
"customRate": 123
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 123, days: 123, customRate: 123})
};
fetch('https://api.magebank.ai/investment/calculator', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magebank.ai/investment/calculator",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123,
'days' => 123,
'customRate' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.magebank.ai/investment/calculator"
payload := strings.NewReader("{\n \"amount\": 123,\n \"days\": 123,\n \"customRate\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.magebank.ai/investment/calculator")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 123,\n \"days\": 123,\n \"customRate\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/investment/calculator")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 123,\n \"days\": 123,\n \"customRate\": 123\n}"
response = http.request(request)
puts response.read_body{
"principal": 1000,
"days": 365,
"interestRate": 4.5,
"interestEarned": "45.00",
"totalAmount": "1045.00",
"annualYield": "4.50%",
"calculation": {
"formula": "principal × rate × (days ÷ 365)",
"steps": [
"1000 × 0.045 × 365/365",
"1000 × 0.045 × 1.000000",
"1000 × 0.045 × 0.045000",
"45.000000"
]
}
}
{
"success": false,
"error": "Amount and days are required"
}
{
"success": false,
"error": "Amount must be a positive number"
}
{
"success": false,
"error": "Days must be a positive number"
}
{
"error": "Internal server error"
}
Savings
Calculate Interest
Calculate potential interest
POST
/
investment
/
calculator
Calculate Interest
curl --request POST \
--url https://api.magebank.ai/investment/calculator \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"amount": 123,
"days": 123,
"customRate": 123
}
'import requests
url = "https://api.magebank.ai/investment/calculator"
payload = {
"amount": 123,
"days": 123,
"customRate": 123
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount: 123, days: 123, customRate: 123})
};
fetch('https://api.magebank.ai/investment/calculator', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magebank.ai/investment/calculator",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123,
'days' => 123,
'customRate' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.magebank.ai/investment/calculator"
payload := strings.NewReader("{\n \"amount\": 123,\n \"days\": 123,\n \"customRate\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.magebank.ai/investment/calculator")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 123,\n \"days\": 123,\n \"customRate\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/investment/calculator")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 123,\n \"days\": 123,\n \"customRate\": 123\n}"
response = http.request(request)
puts response.read_body{
"principal": 1000,
"days": 365,
"interestRate": 4.5,
"interestEarned": "45.00",
"totalAmount": "1045.00",
"annualYield": "4.50%",
"calculation": {
"formula": "principal × rate × (days ÷ 365)",
"steps": [
"1000 × 0.045 × 365/365",
"1000 × 0.045 × 1.000000",
"1000 × 0.045 × 0.045000",
"45.000000"
]
}
}
{
"success": false,
"error": "Amount and days are required"
}
{
"success": false,
"error": "Amount must be a positive number"
}
{
"success": false,
"error": "Days must be a positive number"
}
{
"error": "Internal server error"
}
Investment Planning: Project potential earnings on investments with detailed calculation breakdowns for financial planning.
Request Headers
string
required
Your API key for authentication
Request Body
number
required
Principal amount to invest
number
required
Investment duration in days
number
Optional custom interest rate (annual percentage)
Response
number
Principal amount for the calculation
number
Duration of the investment in days
number
Annual interest rate applied to the calculation
string
Interest amount earned over the period
string
Total amount including principal and interest
string
Annual percentage yield
object
{
"principal": 1000,
"days": 365,
"interestRate": 4.5,
"interestEarned": "45.00",
"totalAmount": "1045.00",
"annualYield": "4.50%",
"calculation": {
"formula": "principal × rate × (days ÷ 365)",
"steps": [
"1000 × 0.045 × 365/365",
"1000 × 0.045 × 1.000000",
"1000 × 0.045 × 0.045000",
"45.000000"
]
}
}
{
"success": false,
"error": "Amount and days are required"
}
{
"success": false,
"error": "Amount must be a positive number"
}
{
"success": false,
"error": "Days must be a positive number"
}
{
"error": "Internal server error"
}
Status Codes
| Status Code | Description |
|---|---|
| 200 | Interest calculation completed successfully |
| 400 | Invalid request parameters |
| 500 | Internal Error |
Default Rate: If no custom rate is provided, the calculation uses the platform’s current base interest rate.
Simple Interest: The calculator uses a simple interest formula that divides the annual rate by 365 days for daily accrual.