BotGame API Logo Alternate

BotGame API - Documentation

Introduction

Our eval.php API endpoint allows developers to evaluate mathematical expressions securely and reliably. This endpoint supports a wide range of mathematical operators and functions, and it returns results in a JSON format for easy integration with applications.

Request Parameters

  • api_key: Your personal API key for authentication.
  • expr: The mathematical expression you wish to evaluate.

 

Mathematical Operators and Functions

Our API supports the following mathematical operators:

  • Addition: +
  • Subtraction: -
  • Multiplication: *
  • Division: /
  • Exponentiation: ^
  • Parentheses for grouping: ( )

Example:

To evaluate the expression (6 + 4) * 3, pass the expr parameter as (6%2B4)*3.

Encoding URLs

When sending complex expressions, especially those that include special characters like +, it’s important to encode your URLs. Special characters can be misinterpreted by browsers and servers, leading to unexpected results.

In JavaScript, you can use the encodeURIComponent function to safely encode your expressions:

let expression = "(6 + 4) * 3";
let encodedExpression = encodeURIComponent(expression);
let url = "https://botgameapi.com/app/eval?api_key=YOUR_API_KEY&expr=" + encodedExpression;

For other languages, refer to their respective methods/functions for URL encoding.

Sample Request

Request:

https://botgameapi.com/app/eval?api_key=<api_key>&expr=32*32%2B(6%2B4)

Response:

{
    "result": 1034
}

 

2 views