⚠️ xMath API is deprecated. Now it is part of Shadify project.
A free API for generating random mathematical expressions.
The API provides you with the ability to get a random expression with mathematical operations such as addition, subtraction, multiplication or division. You get an object containing two numbers, an operation sign, and the result of an expression.
You can choose the operation you need or get a random operation.
https://x-math.herokuapp.com/api/random
https://x-math.herokuapp.com/api/add
https://x-math.herokuapp.com/api/sub
https://x-math.herokuapp.com/api/mul
https://x-math.herokuapp.com/api/div
By default, the range of numbers from 1 to 99 is set for all expressions. But you can adjust the range (for any operation) yourself using the parameters.
The max and min parameters change the possible range for each number in the expression.
?max=999&min=100
The maxFirst and minFirst parameters change the possible range only for the first number (the second number uses the default value).
?maxFirst=256&minFirst=128
The maxSecond and minSecond parameters change the possible range only for the second number (does not affect division, because there the second number is randomly selected from the list of divisors of the first number).
?maxSecond=256&minSecond=128
To get expressions that result in negative numbers, you can change the range of values using the parameters described above by adding negative numbers there.
But this will not work for the subtraction operation, because by default there the first number is always greater than the second. To fix this, you can use the parameter negative in the value 1.
https://x-math.herokuapp.com/api/sub?negative=1
https://x-math.herokuapp.com/api/random?max=999&negative=1
https://x-math.herokuapp.com/api/mul?maxFirst=999&maxSecond=20
https://x-math.herokuapp.com/api/add?max=500&minFirst=100
In the project directory, you can:
- Run the server with Nodemon for development
npm run dev
The page will reload if you make edits.
You will also see any lint errors in the console.
Open http://localhost:5000 to view it in the browser.
- Launch tests
npm run test
- Create a production build
npm run build
- Runs the server of production build
npm start
Open http://localhost:5000 to view it in the browser.