logo

math.js web service

math.js is available as a RESTful API. Evaluations can be done via GET or POST requests. The duration per evaluation of this free service is limited to 10 seconds, with a maximum of 10,000 requests per day.

GET

HTTP Request

GET http://api.mathjs.org/v4/

Query parameters

Name Type Required Description
expr string yes The expression to be evaluated. The expression must be url encoded.
precision number no Number of significant digits in formatted output. Undefined by default.

Response

On success, the response will have status 200 and the body contains the result of the expression. On failure, the response will have status 400 with an error message in the body.

Examples

Try it

Expression
Url loading...

POST

HTTP Request

POST http://api.mathjs.org/v4/

Headers

Must contain the following header:

content-type: application/json

Request Body

The request body must contain a JSON Object with the following fields:

Name Type Required Description
expr string or string[] yes A string containing the expression to be evaluated, or an array with strings to be evaluated
precision number no Number of significant digits in formatted output. Undefined by default.

Response

The response is a JSON object containing the following fields:

Name Type Description
result string, string[], or null On success, the field result contains a string with the results of the expression. If an array with expressions was provided, the result will be a an array with a string for each expression. On failure, result will be null.
error string or null On failure, error will contain an error message. On success, error will be null.

Try it