
Percentage Calculator API
Finance
Work out X% of a number, what percent one number is of another, the percentage change between two values, or add and subtract a percentage, with the formula shown.
Authentication
Send your API key as a Bearer token in the Authorization header (Authorization: Bearer YOUR_API_KEY), or in an X-API-Key header.
Rate Limit
120 requests per minute
Endpoints
2 endpoints available
Overview
Pick an operation and send the fields it needs:
percent-of: what ispercent% ofvalue?what-percent:partis what percent ofwhole?percent-change: the change fromfromtoto, as a percentage of the starting value. A change from -50 to -25 is a 50% increase. The response also haspercentDifference, which compares the two values with their average, for when neither is the starting point.add-percent:valueincreased bypercent%, for tax or markup.subtract-percent:valuedecreased bypercent%, for a discount.
Notes
- Results have floating-point noise removed (rounded to 10 decimal places), so 7% of 1000 is 70, not 70.00000000000001.
what-percentwith a whole of 0 andpercent-changefrom 0 have no answer and return a 400 error.- Numbers can be negative. Values are limited to 1e15 in size.
Endpoints
POST
https://opentools.ca/api/v1/tools/percentage-calculatorSolve common percentage questions
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| operation | string Enum: percent-of, what-percent, percent-change, add-percent, subtract-percent | Required | Which question to answer. |
| percent | number | Optional | The percentage. Used by percent-of, add-percent and subtract-percent. |
| value | number | Optional | The number to work on. Used by percent-of, add-percent and subtract-percent. |
| part | number | Optional | The part. Used by what-percent. |
| whole | number | Optional | The whole, not 0. Used by what-percent. |
| from | number | Optional | The starting value, not 0. Used by percent-change. |
| to | number | Optional | The new value. Used by percent-change. |
Response Example
{
"success": true,
"operation": "percent-of",
"percent": 20,
"value": 150,
"result": 30
}Error Codes
400
Bad Request - A field is missing or invalid. The response lists each problem.401
Unauthorized - Missing or invalid API key403
Forbidden - The API key is inactive or expired, or the request IP is not allowed405
Method Not Allowed - This endpoint accepts GET and POST only429
Too Many Requests - Rate limit exceeded (120 requests per minute per API key)500
Internal Server ErrorGET
https://opentools.ca/api/v1/tools/percentage-calculatorSolve common percentage questions. Same fields as the POST body, sent as query parameters.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| operation | string Enum: percent-of, what-percent, percent-change, add-percent, subtract-percent | Required | Which question to answer. |
| percent | number | Optional | The percentage. Used by percent-of, add-percent and subtract-percent. |
| value | number | Optional | The number to work on. Used by percent-of, add-percent and subtract-percent. |
| part | number | Optional | The part. Used by what-percent. |
| whole | number | Optional | The whole, not 0. Used by what-percent. |
| from | number | Optional | The starting value, not 0. Used by percent-change. |
| to | number | Optional | The new value. Used by percent-change. |
Response Example
{
"success": true,
"operation": "percent-of",
"percent": 20,
"value": 150,
"result": 30
}Error Codes
400
Bad Request - A field is missing or invalid. The response lists each problem.401
Unauthorized - Missing or invalid API key403
Forbidden - The API key is inactive or expired, or the request IP is not allowed405
Method Not Allowed - This endpoint accepts GET and POST only429
Too Many Requests - Rate limit exceeded (120 requests per minute per API key)500
Internal Server ErrorCode Examples
# What is 20% of 150
curl -X POST https://opentools.ca/api/v1/tools/percentage-calculator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"operation": "percent-of",
"percent": 20,
"value": 150
}'
# Percentage change from 80 to 100
curl -X POST https://opentools.ca/api/v1/tools/percentage-calculator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"operation": "percent-change",
"from": 80,
"to": 100
}'
# The same request as a GET with query parameters
curl "https://opentools.ca/api/v1/tools/percentage-calculator?operation=percent-of&percent=20&value=150" \
-H "Authorization: Bearer YOUR_API_KEY"Rather use it in your browser? Open the Percentage Calculator