> For the complete documentation index, see [llms.txt](https://infinitode-docs.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitode-docs.gitbook.io/documentation/api-documentation/simple-interest-calculator-api-documentation.md). Agents can also search and read this documentation through its [MCP server](https://infinitode-docs.gitbook.io/documentation/~gitbook/mcp).

# Simple Interest Calculator API Documentation

This API allows you to calculate simple interest based on the time in months and the rate of interest.

## :rocket: Quickstart Using cURL

Set `INFINITODE_API_KEY` in your local or server environment to your standard API key (`INF-`). Do not commit the key.

```bash
curl -X POST "https://infinitode.netlify.app/api/v1/simple-interest-calculator" \
     -H "Authorization: Bearer $INFINITODE_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"principal": 125, "rate": 0.15, "timeInMonths": 12}'
```

## Changelog

* **1.1 (Latest)**: Updated API security.
* **1.0**: Initial commit for API space.

## Access

The API can be accessed from

```html
https://infinitode.netlify.app/api/v1/simple-interest-calculator
```

***

## Authentication

Use your account's **standard API key** (`INF-`) with `POST` over HTTPS. **Recommended:** send it in the `Authorization` header:

```http
Authorization: Bearer YOUR_API_KEY
```

The `apiKey` field in the POST JSON body remains a supported fallback, but all new integrations should use the header. When the `Authorization` header is present, `apiKey` is ignored. Keep the key on your server; see [Keeping your API key safe](https://infinitode-docs.gitbook.io/documentation/api-documentation/keeping-your-api-key-safe.md).

{% hint style="warning" %}
**Deprecated: GET will be removed on 1 January 2027.** Until then, legacy GET requests still work, including the deprecated `token` query parameter. When the `Authorization` header is present, `token` is ignored. URLs can expose keys through access logs, proxies, browser history and referrer headers. Switch to **POST with `Authorization: Bearer <key>`** before the deadline; adding a header to GET alone is not enough. See [Migrating from GET](https://infinitode-docs.gitbook.io/documentation/api-documentation.md#migrating-from-get).
{% endhint %}

***

## Endpoint

### Calculate Simple Interest

Endpoint URL:

```
https://infinitode.netlify.app/api/v1/simple-interest-calculator
```

HTTP Methods:

* `POST` — recommended; parameters in the JSON body.
* `GET` — **deprecated; removed on 1 January 2027**.

Request Body

The request body should be a JSON object with the following properties:

* `apiKey`: Optional authentication fallback when the `Authorization` header is absent; omit it when using the header.
* `principal`: The starting value, without interest.
* `rate`: The rate at which interest is applied (15% -> 0.15).
* `timeInMonths`: The time in months.

Example:

```json
{
  "principal": 125,
  "rate": 0.15,
  "timeInMonths": 12
}
```

Response

Upon a successful request, you will receive a JSON response with the calculated interest, monthly total, and the final total. If the API token is invalid or the request fails for any reason, an error message will be included in the response.

Example response:

```json
{
    "output": {
        "interest": 25,
        "totalAmount": 125,
        "monthlyAmount": 25
    }
}
```

The response contains the calculated interest, the monthly total and the final total.

***

## Usage example

Here's a server-side JavaScript example using `fetch` (Node.js):

```javascript
const apiUrl = 'https://infinitode.netlify.app/api/v1/simple-interest-calculator';

const data = {
  "principal": 125,
  "rate": 0.15,
  "timeInMonths": 12
};

fetch(apiUrl, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${process.env.INFINITODE_API_KEY}`,
  },
  body: JSON.stringify(data),
})
  .then(response => response.json())
  .then(result => {
    console.log('Interest and Total:', result.output);
  })
  .catch(error => {
    console.error('Error:', error);
  });
```

Run this example on your server with `INFINITODE_API_KEY` set to your standard API key in the environment.

{% hint style="warning" %}
Keep `INFINITODE_API_KEY` in your server's environment, not in public front-end code or a committed environment file. A header does not hide a key from someone who controls the browser. To try the request without a key at all, use mock mode in the [API playground](https://infinitode.netlify.app/api/playground). In production, call the API from your own server or a serverless function, and have your front end call that. See [Keeping your API key safe](https://infinitode-docs.gitbook.io/documentation/api-documentation/keeping-your-api-key-safe.md).
{% endhint %}

***

## Error handling

The API may return error responses in case of invalid input or other issues. Be sure to handle errors gracefully in your application. Error responses will include appropriate status codes and error messages in the JSON format.

***

## Parameters

Here are all the available parameters for the API:

#### `POST` method

| Parameter      | Description                                                                                       | Optional |
| -------------- | ------------------------------------------------------------------------------------------------- | -------- |
| `apiKey`       | Authentication fallback only if the `Authorization` header is absent; omit when using the header. | `true`   |
| `principal`    | The starting value (number) to calculate interest on.                                             | `false`  |
| `rate`         | The rate of interest (number) to use when calculating interest.                                   | `false`  |
| `timeInMonths` | The time in months (number) to calculate interest on.                                             | `false`  |

#### `GET` method (deprecated — removed on 1 January 2027)

| Parameter      | Description                                                                                              | Optional |
| -------------- | -------------------------------------------------------------------------------------------------------- | -------- |
| `token`        | **Deprecated.** Legacy GET authentication fallback when the header is absent; removed on 1 January 2027. | `true`   |
| `principal`    | The starting value (number) to calculate interest on.                                                    | `false`  |
| `rate`         | The rate of interest (number) to use when calculating interest.                                          | `false`  |
| `timeInMonths` | The time in months (number) to calculate interest on.                                                    | `false`  |

***

## :warning: Error codes

Here are a few of the error codes, you will receive in responses, to help clarify issues:

#### Common error codes

<table><thead><tr><th width="177">Error code</th><th>Description</th></tr></thead><tbody><tr><td><code>400</code></td><td>Missing or invalid parameters. This is when the parameters you passed to the API, do not match the API's expected inputs.</td></tr><tr><td><code>405</code></td><td>Using an invalid method, to access the API.</td></tr><tr><td><code>429</code></td><td>The rate limit is exceeded within the current timeframe.</td></tr><tr><td><code>401</code></td><td>Invalid API key, no remaining calls (<code>No remaining API calls.</code>), or an error while processing your input.</td></tr></tbody></table>

{% hint style="info" %}
Our APIs are rigorously tested before deployments, to ensure that they do not produce any unintentional errors during production.
{% endhint %}

***

## :hourglass: Rate limiting

We use rate limiting, to protect our API's resources. Rate limiting is implemented on all of our APIs, and follows these general principles:

* `interval`: The rate limiting is set to a default interval of `1 minute`.
* `amount of requests`: The amount of requests is set to a default of `25 requests` within the given interval.

If the rate limit is exceeded, an error `429` code will be returned, instead of the actual API output.

***

## :star: Best practices

Common guidelines to use, optimize, and protect your implementation of our APIs.

* Keep your API key in server-side environment variables; never expose it in public code, URLs or logs. See [Keeping your API key safe](https://infinitode-docs.gitbook.io/documentation/api-documentation/keeping-your-api-key-safe.md)
* Implement data cleaning, and validation in your code, to ensure inputs are sanitized
* Handle API errors gracefully
* Try this endpoint in the [API playground](https://infinitode.netlify.app/api/playground) — mock mode returns dummy data in the real response shape, with no API key and no calls used
* Handle API outputs accordingly. You can see examples of this API's output in the [#endpoint](#endpoint "mention") section.
* Implement code to notify users of actions when using our APIs, such as errors, delays, formatting issues, etc.

***

## :question: FAQs

Answers to the most common questions and issues when using this API:

<details>

<summary>I am getting a <code>405</code> error, what should I do?</summary>

A `405` error means the endpoint exists, but the HTTP method doesn't: use `POST`. Legacy `GET` is deprecated and will be removed on 1 January 2027. A `404` or `NotFound` error is different — it means the route doesn't exist, usually because the endpoint URL was misspelled.

</details>

<details>

<summary>Is rate limiting set individually, or per API key?</summary>

Rate limiting is set `individually`, this means that rate limiting happens on an end-user level. This ensures that our API is used fairly, among all users.

</details>

<details>

<summary>Are request timeouts a thing?</summary>

Yes, we normally timeout requests after the 10-second mark. This, however, can vary significantly, depending on various other factors.

</details>

<details>

<summary>What is the max payload size?</summary>

The maximum payload size for `buffered executions` is `4.5mb` per request. For `streamed executions`, we use a payload restriction size of `20mb` per request.

</details>

<details>

<summary>What is the recommended way to call the API?</summary>

Use `POST` over HTTPS with `Authorization: Bearer <key>` and parameters in the JSON body. GET is deprecated and will be removed on **1 January 2027**; credentials in URLs can leak through logs, browser history, proxies and referrer headers. The POST-body `apiKey` fallback remains supported, but the header is recommended.

</details>

***

## OpenAPI

You can download the OpenAPI specification for this API to learn more about how it works and how to use it. The OpenAPI specification is a standard, language-agnostic interface to RESTful APIs that allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.

[Download OpenAPI Specification](https://infinitode.netlify.app/openapi/simple-interest-calculator/openapi.yaml)

***

## Conclusion

That's it! You now have the basics to use the Simple Interest Calculator API. If you have any further questions or encounter issues, please contact our support team.
