Ratias provides a free, open-access mathematical API. Developers can programmatically access our catalog of 13 localized percentage formulas, or execute real-time calculations directly through our high-performance endpoints.
Postman Collection
Download our pre-configured Postman Collection containing all 13 mathematical percentage calculation endpoints to start testing instantly.
1. Formula Metadata API
Retrieve the complete schema, parameters, and localized descriptions for all 13 mathematical formulas:
Response Structure Example
{
"api_version": "1.1",
"total_formulas": 13,
"formulas": [
{
"id": "formula1",
"slugs": { "en": "percentage-calculator", "tr": "yuzde-hesaplama", "de": "prozentrechner", "fr": "calculateur-pourcentage" },
"math_formula": "Result = (A * B) / 100",
"description": { "en": "Calculates B percent of A.", "tr": "A sayısının yüzde B'sini hesaplar.", "de": "Berechnet B Prozent von A.", "fr": "Calcule B pour cent de A." },
"parameters": { ... }
}
]
}2. Real-Time Calculation API
Compute mathematical values dynamically by sending query parameters to the serverless calculate endpoint. The response returns the numerical result, the mathematical formula, and a grammatically correct natural language string in the selected language.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
formula | String / Number | Yes | The formula identifier (e.g. 1, formula1 up to 13). |
val1 | Number | Yes | First parameter value (Base number, sales price, etc.). |
val2 | Number | Yes | Second parameter value (Percentage rate, cost, etc.). Not required for some specific edge cases. |
val3 | Number | No | Third parameter value (Required for formulas 8, 10, 13). |
val4 | Number | No | Fourth parameter value (Required for formula 13). |
lang | String | No | Output language: en, tr, de, fr (default: en). |
Example Request
Example Response
{
"success": true,
"formula": "formula1",
"lang": "en",
"inputs": {
"val1": 150,
"val2": 20
},
"data": {
"result": 30,
"text": "20% of 150 is 30",
"formula": "(150 × 20) ÷ 100 = 30"
}
}3. Integration Code Examples
JavaScript (Fetch API)
// Perform a calculation programmatically
fetch('https://www.ratias.com/api/calculate?formula=13&val1=1000&val2=200&val3=18&val4=20&lang=en')
.then(response => response.json())
.then(data => {
if (data.success) {
console.log("Calculated Result:", data.data.result);
console.log("Output Text:", data.data.text);
} else {
console.error("Calculation Error:", data.error);
}
});Python
import requests
# Query calculation endpoint
params = {
'formula': 1,
'val1': 150,
'val2': 20,
'lang': 'en'
}
response = requests.get("https://www.ratias.com/api/calculate", params=params)
data = response.json()
if data['success']:
print(f"Result: {data['data']['result']}")
print(f"Explanation: {data['data']['text']}")cURL
curl -X GET "https://www.ratias.com/api/calculate?formula=1&val1=150&val2=20&lang=en"4. Mathematical Formula Reference Table
The following table maps formula IDs to their standard mathematical equations and required inputs:
| ID | Name | Mathematical Formula | Inputs Required |
|---|---|---|---|
formula1 | Percentage Calculator | (A × B) ÷ 100 | val1 (A), val2 (B) |
formula2 | Percentage Add | A × (1 + B ÷ 100) | val1 (A), val2 (B) |
formula3 | Reverse Percentage (Excl. VAT) | A ÷ (1 + B ÷ 100) | val1 (A), val2 (B) |
formula4 | Percentage Exclude | A × (1 - B ÷ 100) | val1 (A), val2 (B) |
formula5 | Ratio Calculator | (A ÷ B) × 100 | val1 (A), val2 (B) |
formula6 | Percentage Increase | ((A ÷ B) - 1) × 100 | val1 (A), val2 (B) |
formula7 | Percentage Decrease | ((B - A) ÷ B) × 100 | val1 (A), val2 (B) |
formula8 | Large Number Percentage | (B ÷ A) × C | val1 (A), val2 (B), val3 (C) |
formula9 | Discount Percentage | ((B ÷ A) - 1) × 100 | val1 (A), val2 (B) |
formula10 | Compound Growth | A × (1 + B/100)^C | val1 (A), val2 (B), val3 (C) |
formula11 | Percentage Difference | |A - B| ÷ ((A + B) ÷ 2) × 100 | val1 (A), val2 (B) |
formula12 | Percentage Error | |B - A| ÷ |A| × 100 | val1 (A), val2 (B) |
formula13 | Net Profit Calculator | (A / (1 + C/100) - B) * (1 - D/100) | val1 (A), val2 (B), val3 (C), val4 (D) |
5. License and Attribution
The Ratias Open Math API is released under the MIT License and can be used for both commercial and non-commercial purposes. Linking back to Ratias as the data source is highly appreciated.