I've always liked math, so one of my open source projects was an oral counting simulator. To do this, I wrote code that generates random expressions right inside the application. Now, I decided to separate the application logic and make a free API out of it so that you can create your cool apps.

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