View Categories

Get Message Credits Usage

1 min read

The chat.smarterbot.ai API provides functionality to retrieve message credits usage information by sending a GET request to the /chat/Chatbot/GetMessageCreditsUsage endpoint.

Endpoint #

Request URL: https://chat.smarterbot.ai/chat/Chatbot/GetMessageCreditsUsage

Method: GET

Request Headers #

The API request must include the following headers:

  • Authorization: <Your-Secret-Key> – string, required – The secret key for authenticating the API request

Example Request #

JavaScript (Fetch API) #

const res = await fetch('https://chat.smarterbot.ai/chat/Chatbot/GetMessageCreditsUsage', {
method: 'GET',
headers: {
"Authorization": "<Your-Session-Key>"
},
body: JSON.stringify({})
});

const data = await res.json();
console.log(data);

Python (Requests Library) #

import requests
import json

url = 'https://chat.smarterbot.ai/chat/Chatbot/GetMessageCreditsUsage'
headers = {
"Authorization": "<Your-Session-Key>"
}
data = {}

response = requests.get(url, headers=headers, json=data)
data = response.json()
print(data)

cURL #

curl 'https://chat.smarterbot.ai/chat/Chatbot/GetMessageCreditsUsage' \
-X GET \
-H 'Authorization: <Your-Session-Key>' \
-d '{}'

HTTP Request #

GET /chat/Chatbot/GetMessageCreditsUsage HTTP/1.1
Host: chat.smarterbot.ai
Authorization: <Your-Session-Key>

{}

Response #

The API response will be a JSON object with the following structure:

{
// object - Message credits usage information
"Data": {
"Total": -1,
"Used": 243,
"Remain": -1
},
// string - API version
"Version": "1.0.0",
// boolean - Operation success status
"Success": true,
// integer - HTTP status code
"Code": 200,
// string - Error message if any
"Message": ""
}

Error Handling #

If the request fails, you should: 1. Check the HTTP status code for network-level errors 2. Examine the `Code` and `Message` fields in the response for business-level errors 3. The `Message` field will contain detailed error information

Leave a Reply

Your email address will not be published. Required fields are marked *