Skip to content
POST AI agent ready /v1/math/evaluate

Math Evaluate API - Free Expression Calculator

Evaluate a mathematical expression string and return the numeric result. Supports basic arithmetic (+, -, *, /), powers (^), parentheses, and functions like sqrt, sin, cos, tan, log, and abs. No code execution; the expression is parsed safely.

Parameters

stringrequired

The math expression to evaluate.

Code examples

curl -X POST https://api.botoi.com/v1/math/evaluate \
  -H "Content-Type: application/json" \
  -d '{"expression":"2 * (3 + 4)"}'

When to use this API

Spreadsheet formula evaluation

Evaluate user-entered formulas in a spreadsheet-like app without exposing an eval() function or running untrusted code.

Pricing calculators

Let administrators define pricing rules as math expressions (e.g., "base_price * 1.15 + handling_fee") and evaluate them at runtime.

Educational tools

Build a calculator or math tutoring app that validates student answers by evaluating the expected expression server-side.

Frequently asked questions

Is this safe from code injection?
Yes. The expression is parsed with a math-specific parser, not JavaScript eval(). Only mathematical operators and functions are allowed.
Which functions are supported?
Supported functions include sqrt, cbrt, abs, ceil, floor, round, sin, cos, tan, asin, acos, atan, log (natural), log10, log2, exp, and pow.
Can I use variables in the expression?
No. The expression must contain only numeric literals, operators, and built-in functions. Substitute variable values before sending.
What precision does the result have?
Results use IEEE 754 double-precision floating point, same as JavaScript. For financial calculations, round the result to the needed decimal places.

Get your API key

Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.