Engineering Calculator API
Mars the Limit's Calculator API can solve for a missing variable for any supported formula and returns a detailed result about the solution and the formula used to get there.
I also included support for multiple variations of equations. For example, Joule's Law can be calculated like or .
Built for students, engineers, builders, and developers, this API is meant to be useful and time saving for all levels of experience.
Quick Start Guide
URL: https://api.marsthelimit.com/calculate
Authentication: API Key required via header ("Authorization": "Bearer YOUR_API_KEY")
Supported format: JSON
To use the engineering API, send a request with 2 parameters:
| Parameter | Value |
|---|---|
formula | A string of the law name. Case sensitive. |
vars | Object containing variables used in the equation. |
Example request:
1{ 2 "formula": "ohm", 3 "vars": { 4 "V": 12, 5 "I": 2 6 } 7}
Example response:
1{ 2 "I": 2, 3 "R": "None", 4 "V": 12, 5 "power": 24, 6 "solved": "R", 7 "summary": "R = V/I = 6 Ω", 8 "value": 6.0 9}
Supported Formulas
More formulas will be added in later versions. Currently, only a handful of electrical engineering formulas are supported.
| Formula | Formula String | Variables (Simplified) |
|---|---|---|
| Faraday's Law | faraday | emf, N, flux, t, B, signed |
| Ohm's Law | ohm | V, I, R |
| Joule's Law | joule | Q, P, I, R, t |
| Coulomb's Law | coulomb | F, q1, q2, q_product, r, epsilon_r, k, signed |
| Watt's Law | watt | P, V, I |
For a more in-depth look at the laws, check out their individual pages linked in the table.
General API Behavior
The API can automatically solve for a missing variable in a supported engineering or physics formula based on the inputs you provide.
Solving Logic
-
You provide known variables inside the
varsobject and specify theformula. -
The API determines the missing variable and solves for it.
-
Only one primary variable can be missing for the solver to work predictably.
-
If multiple variables are missing, the API will attempt to infer the intended variables, but results are not guaranteed.
Variable Conventions
-
Variables are case-sensitive and must match the expected keys for the selected law.
-
Most variables follow the standard engineering notation.
- Ex. is voltage, is current, etc.
Units
All inputs are expected to be in SI units:
- volts (V), amps (A), ohms (Ω), watts (W), meters (m), coulombs (C), newtons (N), seconds (s)
The API does not automatically convert units, so make sure your units are consistent.
Delta & Initial-Final Values
Many laws support change over time or initial/final values.
You can pass either:
-
a direct delta value (e.g., flux, t)
-
or initial and final values (e.g., flux_i, flux_f, t_i, t_f)
The API will compute and use that in the calculation.
Derived Values
In addition to the solved variable, the API may return derived values when possible.
Examples:
-
power from Ohm's Law:
- P=VI
-
energy from Watt's Law over time
-
electric field from Coulomb's Law
These appear as additional fields in the response.
Sign Conventions
Some laws support directional or signed outputs.
When signed = true, the API will preserve the sign of the result based on the physics of the equation (e.g., attraction vs repulsion in electrostatics).
When signed = false, the API returns the magnitude only.
Precision and Formatting
Numerical outputs are returned as floating-point values.
The summary field provides a human-readable equation substitution, such as
This is meant to be for display in user interfaces or educational tools.
Error Handling Behavior
The API will return an error if:
-
required variables are missing
-
values cause non-real answers or errors (e.g., division by zero)
-
the formula identifier is not supported
-
conflicting or inconsistent inputs are provided
-
Error responses include a message describing the issue so it can be handled programmatically.
Stateless Requests
Each API request is stateless. No session or stored context is used and every request must include all necessary variables
This makes the API easy to integrate into:
-
web apps
-
calculators
-
automation scripts
-
educational tools
About the Author
This article was written by Boden Bensema, an electronics hobbyist focused on teaching beginner-friendly circuit design, breadboarding, and electronics fundamentals.
About page