Skip to main content

Using Custom API Endpoints

MadBot allows you to create custom API endpoints to interact with your bot. This is useful for creating custom commands, or for creating custom integrations with other services.

Calling a Custom API Endpoint

To call a custom endpoint, use either the CALL_API_CACHE or CALL_API functions.

"function": "CALL_API_CACHE",
"params": ["GetCommits", "GithubHeader", "", ""],
"output": "$ANSWER"

Configuring a Custom API Endpoint

Configure the API Header

To use an endpoint, you'll first need to configure the header in the API directory of the bot. Here's an example for calling the GitHub API:


"Accept": "application/vnd.github+json",
"Authorization": "Bearer ...",
"X-GitHub-Api-Version": "2022-11-28",
"User-Agent": "request"

Configure an API Endpoint

To configure an API endpoint, you'll need to create a new file in the API directory of your bot. The file should be named after the endpoint you want to create, and should have a .json extension. Here's an example of a simple endpoint that returns a list issues from the GitHub API:


"apiUrl": "",
"method": "GET",
"body": null