Simple Interest Calculator API Documentation
This API allows you to calculate simple interest based on the time in months and the rate of interest.
Changelog
1.1 (Latest): Updated API security.
1.0: Initial commit for API space.
Access
The API can be accessed from
Authentication
API Token
To use this API, you must include an API token in the request. The API token should be included in the request body as the apiKey
field.
You can also use the API with the default GET
method.
Endpoint
Calculate Simple Interest
Endpoint URL:
HTTP Methods:
Post
Get
Request Body
The request body should be a JSON object with the following properties:
apiKey
: Your API token.principal
: The starting value, without interest.rate
: The rate at which interest is applied (15% -> 0.15).timeInMonths
: The time in months.
Example:
Or, use the GET
method:
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. For developer API calls, validation results will also be included along with dummy content.
Example response:
The response includes the calculated interest, the total amount, and the interest. Validation results for the inputs are excluded, since this was a normal API call.
Usage example
Here's a usage example in JavaScript using the fetch
API:
Make sure to replace 'YOUR_API_TOKEN'
with your actual API token.
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 |
---|---|---|
| Your API key, either the developer API key, or your normal API key |
|
| The starting value (number) to calculate interest on. |
|
| The rate of interest (number) to use when calculating interest. |
|
| The time in months (number) to calculate interest on. |
|
`GET` method
Parameter | Description | Optional |
---|---|---|
| Your API key, either the developer API key, or your normal API key |
|
| The starting value (number) to calculate interest on. |
|
| The rate of interest (number) to use when calculating interest. |
|
| The time in months (number) to calculate interest on. |
|
⚠️ Error codes
Here are a few of the error codes, you will receive in responses, to help clarify issues:
Common error codes
Error code | Description |
---|---|
| Missing or invalid parameters. This is when the parameters you passed to the API, do not match the API's expected inputs. |
| Using an invalid method, to access the API. |
| The rate limit is exceeded within the current timeframe. |
| Error during the request. This can be because of insufficient API calls, input errors, or errors arising from the API's logic. |
Our APIs are rigorously tested before deployments, to ensure that they do not produce any unintentional errors during production.
⌛ 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.
⭐ Best practices
Common guidelines to use, optimize, and protect your implementation of our APIs.
Do not store/share/expose your API keys
Implement data cleaning, and validation in your code, to ensure inputs are sanitized
Handle API errors gracefully
Use Developer API calls, to help debug your implementation and code
Handle API outputs accordingly. You can see examples of this API's output in the Endpoint section.
Implement code to notify users of actions when using our APIs, such as errors, delays, formatting issues, etc.
❓ FAQs
Answers to the most common questions and issues when using this API:
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.
Last updated