Math Calculator API
A free, public REST API for computing percentages, fractions, derivatives, quadratic equations, standard deviation, slope, triangles, and matrices. Returns structured JSON with step-by-step solutions and LaTeX notation.
Base URL
https://mathcalculator.org/api/v1All requests are made via POST to /api/v1/calculate with a JSON body. Machine-readable documentation is available at GET /api/v1/docs.
Request Format
{
"type": "percentage | fraction | derivative | quadratic | standard-deviation | slope | triangle | matrix",
"params": { ... }
}type (string, required) — the calculator to use.
params (object, required) — parameters for the calculation (varies by type).
Response Format
{
"result": { ... },
"steps": ["Step 1", "Step 2", ...],
"latex": "\\frac{25}{100} \\times 200 = 50"
}result — the computed answer (shape depends on calculator type).
steps — array of human-readable step-by-step explanations.
latex — LaTeX string for rendering the solution.
Percentage Calculator
Five modes: of, is, change, difference, reverse.
Example: What is 25% of 200?
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "percentage", "params": { "a": 25, "b": 200, "mode": "of" } }'| Param | Type | Description |
|---|---|---|
| a | number | First value |
| b | number | Second value |
| mode | string | "of" | "is" | "change" | "difference" | "reverse" (default: "of") |
Fraction Calculator
Operations: add, subtract, multiply, divide, simplify. Results are always returned in simplest form.
Example: Add 1/3 + 1/6
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "fraction", "params": { "num1": 1, "den1": 3, "num2": 1, "den2": 6, "operation": "add" } }'| Param | Type | Description |
|---|---|---|
| num1, den1 | integer | First fraction |
| num2, den2 | integer | Second fraction (not needed for simplify) |
| operation | string | "add" | "subtract" | "multiply" | "divide" | "simplify" (default: "add") |
Derivative Calculator
Symbolic differentiation powered by mathjs. Supports higher-order derivatives up to 10th order.
Example: Derivative of x^3 + 2*x^2 - 5*x
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "derivative", "params": { "expression": "x^3 + 2*x^2 - 5*x", "variable": "x" } }'| Param | Type | Description |
|---|---|---|
| expression | string | Mathematical expression (e.g. "x^2 + 3*x") |
| variable | string | Variable to differentiate with respect to (default: "x") |
| order | integer | Derivative order, 1-10 (default: 1) |
Quadratic Equation Solver
Solves ax² + bx + c = 0. Returns roots (real or complex), discriminant, vertex, and axis of symmetry.
Example: Solve x² - 5x + 6 = 0
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "quadratic", "params": { "a": 1, "b": -5, "c": 6 } }'| Param | Type | Description |
|---|---|---|
| a | number | Coefficient of x² (must not be 0) |
| b | number | Coefficient of x |
| c | number | Constant term |
Standard Deviation Calculator
Calculate mean, variance, and standard deviation for a data set. Supports both population and sample standard deviation.
Example: Population standard deviation of [10, 20, 30, 40, 50]
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "standard-deviation", "params": { "values": "10,20,30,40,50", "type": "population" } }'Example: Sample standard deviation (array format)
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "standard-deviation", "params": { "values": [85, 90, 78, 92, 88], "type": "sample" } }'| Param | Type | Description |
|---|---|---|
| values | string or array | Comma-separated numbers or array (e.g. "10,20,30" or [10,20,30]) |
| type | string | "population" | "sample" (default: "population") |
Slope Calculator
Calculate slope, y-intercept, distance, and line equation from two points.
Example: Slope between (1, 2) and (4, 8)
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "slope", "params": { "x1": 1, "y1": 2, "x2": 4, "y2": 8 } }'| Param | Type | Description |
|---|---|---|
| x1 | number | x-coordinate of first point |
| y1 | number | y-coordinate of first point |
| x2 | number | x-coordinate of second point |
| y2 | number | y-coordinate of second point |
Triangle Calculator
Calculate area (Heron's formula), perimeter, and angles of a triangle given three side lengths.
Example: Triangle with sides 3, 4, 5
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "triangle", "params": { "a": 3, "b": 4, "c": 5 } }'| Param | Type | Description |
|---|---|---|
| a | number | Length of side a |
| b | number | Length of side b |
| c | number | Length of side c |
Matrix Calculator
Matrix operations: determinant, transpose, or inverse. Supports matrices up to 5x5.
Example: Determinant of a 2x2 matrix
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "matrix", "params": { "matrixA": [[1, 2], [3, 4]], "operation": "determinant" } }'Example: Inverse of a 2x2 matrix
curl -X POST https://mathcalculator.org/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "type": "matrix", "params": { "matrixA": [[4, 7], [2, 6]], "operation": "inverse" } }'| Param | Type | Description |
|---|---|---|
| matrixA | 2D array | Matrix as array of arrays (e.g. [[1,2],[3,4]]) |
| operation | string | "determinant" | "transpose" | "inverse" (default: "determinant") |
Error Handling
Errors return a JSON object with an error field and an appropriate HTTP status code (400 for validation errors).
{ "error": "Parameters \"a\" and \"b\" must be valid numbers." }© 2026 Math Calculator. Free to use.