Discord Bot Stats
Update Bot Stats API
Learn how to update your bot's stats using our API

This documentation will guide you through the process of updating your Discord bot's stats using our API.

To ensure your bot's stats are kept up to date, you'll need to send periodic updates about your bot’s guild count to the API. This should be done using a scheduled task in your bot's code, so it runs on a loop at regular intervals (e.g., every few minutes or hours, depending on your needs).

Once you’ve set up the loop, the data will be automatically saved in the server's db, which you can later use for analytics and tracking growth.

Endpoint
POST http://stats-pearl.vercel.app/api/UpdateStats
Authentication

To authenticate the request, include your API key in the Authorization header:

Authorization: api_######

Replace api_###### with your actual API key.

Request Body

The request body should be a JSON object containing the following data:

{
    "guilds": number
  }

Where guilds is the number of guilds (servers) your bot is currently in.

Example Request

Here's an example of how to make a request using curl:

curl --request POST \
    --url 'http://127.0.0.1:8000/Updatestats' \
    --header 'Authorization: api_######' \
    --header 'Content-Type: application/json' \
    --data '{
      "guilds": 10000
    }'
Response

Upon a successful update, you should receive a response indicating that the stats were updated.

A successful response will look like:

{
    "message": "Stats updated successfully"
  }
Error Handling

If an error occurs, the API will return an appropriate HTTP status code along with an error message.

Here are the common errors:

  • 401 Unauthorized: Invalid or missing API key in the Authorization header.
  • 400 Bad Request: Invalid or missing data in the request body.
  • 404 Not Found: No bot found with the provided API key or no update made.
  • 500 Internal Server Error: Server-side issues like database errors.