API Documentation
Complete REST API reference for developers integrating Calcora into their applications.
Getting Started
Calcora provides a REST API for all mathematical operations. The API is available at:
https://calcoralive.netlify.app/api/v1/
For local development or self-hosting:
http://localhost:5000/api/v1/
Installation (Python Package)
pip install calcora
Quick Start (Desktop App)
Download the Windows Desktop App which includes a built-in API server.
Differentiation
POST
/api/v1/differentiate
Compute the derivative of a mathematical expression with step-by-step explanation.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
expression |
string | REQUIRED | Mathematical expression (e.g., "x**2 + 3*x") |
variable |
string | optional | Variable to differentiate with respect to (default: "x") |
verbosity |
string | optional | Detail level: "concise", "detailed", or "teacher" |
Example Request
curl -X POST https://calcoralive.netlify.app/api/v1/differentiate \
-H "Content-Type: application/json" \
-d '{
"expression": "sin(x)*x**2",
"variable": "x",
"verbosity": "detailed"
}'
Example Response
{
"result": "x**2*cos(x) + 2*x*sin(x)",
"steps": [
{
"step": 1,
"rule": "product_rule",
"input": "sin(x)*x**2",
"output": "sin(x)*Derivative(x**2, x) + x**2*Derivative(sin(x), x)",
"explanation": "Apply product rule: d/dx[f·g] = f·g' + g·f'"
},
{
"step": 2,
"rule": "power_rule",
"input": "Derivative(x**2, x)",
"output": "2*x",
"explanation": "Apply power rule: d/dx[x^n] = n*x^(n-1)"
},
{
"step": 3,
"rule": "chain_rule_sin",
"input": "Derivative(sin(x), x)",
"output": "cos(x)",
"explanation": "d/dx[sin(x)] = cos(x)"
}
],
"metadata": {
"operation": "differentiate",
"input_expression": "sin(x)*x**2",
"output_expression": "x**2*cos(x) + 2*x*sin(x)",
"variable": "x",
"verbosity": "detailed"
}
}
Integration
POST
/api/v1/integrate
Compute the integral of a mathematical expression with step-by-step explanation.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
expression |
string | REQUIRED | Mathematical expression to integrate |
variable |
string | optional | Variable to integrate with respect to (default: "x") |
definite |
boolean | optional | Whether to compute definite integral (requires lower and upper) |
lower |
number/string | optional | Lower bound for definite integral |
upper |
number/string | optional | Upper bound for definite integral |
verbosity |
string | optional | Detail level: "concise", "detailed", or "teacher" |
Example Request (Indefinite)
curl -X POST https://calcoralive.netlify.app/api/v1/integrate \
-H "Content-Type: application/json" \
-d '{
"expression": "x**2 + 3*x",
"verbosity": "detailed"
}'
Example Request (Definite)
curl -X POST https://calcoralive.netlify.app/api/v1/integrate \
-H "Content-Type: application/json" \
-d '{
"expression": "x**2",
"lower": 0,
"upper": 2,
"definite": true
}'
Matrix Operations
POST
/api/v1/matrix/{operation}
Perform various matrix operations.
Available Operations
determinant— Compute matrix determinantinverse— Compute matrix inverseeigenvalues— Compute eigenvaluesrref— Reduced row echelon formlu— LU decompositionrank— Matrix rank
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
matrix |
array | REQUIRED | 2D array representing the matrix |
verbosity |
string | optional | Detail level for steps |
Example Request
curl -X POST https://calcoralive.netlify.app/api/v1/matrix/determinant \
-H "Content-Type: application/json" \
-d '{
"matrix": [[1, 2], [3, 4]]
}'
Error Handling
All endpoints return standard HTTP status codes:
| Status Code | Meaning | Description |
|---|---|---|
200 OK |
Success | Request completed successfully |
400 Bad Request |
Invalid Input | Malformed expression or missing required parameters |
422 Unprocessable Entity |
Mathematical Error | Expression is valid but cannot be computed (e.g., division by zero) |
500 Internal Server Error |
Server Error | Unexpected server error |
Error Response Format
{
"error": "Invalid expression syntax",
"detail": "Unexpected token at position 5",
"expression": "x**2 +",
"code": "SYNTAX_ERROR"
}
Rate Limiting
The public API has rate limits to ensure fair usage:
- Public API: 100 requests per minute per IP
- Desktop App: No rate limits (localhost only)
- Self-Hosted: Configure your own limits
Rate limit headers are included in all responses:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000
Python SDK
For Python developers, use the official SDK for easier integration:
Installation
pip install calcora
Usage Example
from calcora import differentiate, integrate
# Differentiation
result = differentiate("x**2 + 3*x", verbosity="detailed")
print(result.output) # "2*x + 3"
print(result.steps) # List of step-by-step explanations
# Integration
result = integrate("x**2", lower=0, upper=2, definite=True)
print(result.output) # "8/3"
Full Python API documentation: GitHub README
Need Help?
Resources for API developers:
- GitHub Issues — Report bugs or request features
- GitHub Discussions — Ask questions and share ideas
- User Guide — Learn how to use Calcora effectively
- Self-Hosting Guide — Host your own Calcora instance