Skip to content

Work in progress

This documentation page is currently work in progress.
Not all existing DecAPI endpoints are documented here yet - mostly Twitch and YouTube endpoints. The rest of the endpoints should have accurate documentation :)
For the currently active documentation, please visit docs.decapi.me.

Evaluate math expression

Performs a mathematic operation based on the expression passed to the endpoint.
Keep in mind to properly URL-encode exp, so that certain characters are handled correctly.

Thanks to mathjs for providing the library / API for this endpoint.

Handling addition (plus) properly

Especially important with the + (plus) character. If the + character is passed as-is to the URL, it will be interpreted as a space character.
For the API to consider + as an actual "plus" / addition, it needs to be URL-encoded as %2B.
If you're allowing your viewers to use this as a command in your Twitch chat, then there are some bots that have command variables to properly handle this, such as:

The examples at the bottom of this documentation page try to use the correct bot variables for each bot, but the bots listed above are the only ones I know of that will properly encode the + character unless done manually.

Endpoint URL

https://decapi.me/math?exp=369%2B51

Query parameters

  • exp - Required - The mathematic expression to receive the result from.
  • round - Optional - Round to the specified number of decimal places.
    • If specified with 0 or below, or with no value, the result will be rounded to the nearest whole number.

Examples

Examples for bots

Nightbot

Note: Nightbot will automatically convert variables, such as $(channel) or $(touser) to the correct channel name / username, when the command is used.
You do not have to change those variables.

Fossabot

Note: Fossabot will automatically convert variables, such as $(channel) or $(user.login) to the correct channel name / username, when the command is used.
You do not have to change those variables.

StreamElements

Note: StreamElements will automatically convert variables, such as ${channel} or ${touser} to the correct channel name / username, when the command is used.
You do not have to change those variables.

Streamlabs Chat Bot

Note: Streamlabs Chat Bot will automatically convert variables, such as $mychannel or $touserid to the correct channel name / username, when the command is used.
You do not have to change those variables.

Streamlabs Cloudbot

Note: Streamlabs Cloudbot will automatically convert variables, such as {channel.name} or {touser.name} to the correct channel name / username, when the command is used.
You do not have to change those variables.

Deepbot

Note: Deepbot will automatically convert variables, such as @stream@ or @user@ to the correct channel name / username, when the command is used.
You do not have to change those variables.

PhantomBot

Note: PhantomBot will automatically convert variables, such as (channelname) or (touser) to the correct channel name / username, when the command is used.
You do not have to change those variables.