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

NameTypeRequiredDescription
exprstringyesThe expression to be evaluated. The expression must be url encoded.
precisionnumbernoNumber 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
Urlloading...

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:

NameTypeRequiredDescription
exprstring or string[]yesA string containing the expression to be evaluated, or an array with strings to be evaluated
precisionnumbernoNumber of significant digits in formatted output. Undefined by default.

Response

The response is a JSON object containing the following fields:

NameTypeDescription
resultstring, string[], or nullOn 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.
errorstring or nullOn failure, error will contain an error message. On success, error will be null.

Try it