AxelChat API
The AxelChat API provides the ability to integrate third-party software with AxelChat, for example to read messages and viewer information. There are currently three ways to read data from AxelChat: HTTP requests
, WebSocket
and Output to files
HTTP requests
AxelChat can work as a HTTP server. Using HTTP requests, you can receive various data or control the work of AxelChat. Here is a list of HTTP requests supported by the latest version of AxelChat:
http://127.0.0.1:8356/api/v1/set-visibility?main=0
- hide main window AxelChathttp://127.0.0.1:8356/api/v1/set-visibility?main=1
- show main window AxelChathttp://127.0.0.1:8356/api/v1/app
- get information about AxelChat versionhttp://127.0.0.1:8356/api/v1/messages?count=100
- get list of last 100 messageshttp://127.0.0.1:8356/api/v1/selected-messages
- get list of selected messageshttp://127.0.0.1:8356/api/v1/state
- get information about the status of connected platforms, including information about the number of viewers and more
WebSocket
AxelChat can work as a WebSocket server. AxelChat web widgets use exactly this method of communication. The main advantage of this method is instant receipt of messages and various events by your software.
To connect to AxelChat using WebSocket, follow these steps:
- Launch AxelChat
- Open the section
Settings->Developers
. If the WebSocket server was successfully launched, the message “State: Ok” should be displayed - This section will display the URL for connecting to AxelChat via WebSocket, usually
ws://127.0.0.1:8356
. Connect your WebSocket client using this link. See the documentation for your programming language or use the appropriate libraries - If the connection is successful, a new client will be displayed in the
Developers
section - Immediately after connecting, your software should send a message in this format to provide AxelChat with information about your client:
{ "data": { "client": { "name": "<Name of your client>", "version": "<Your client version>" "type": "MAIN_WEBSOCKETCLIENT", }, "info": { "name": "<Additional client name>", "type": "GENERIC" } }, "type": "HELLO" }
If you do not send this message within a few seconds, or send another message, the connection will be automatically terminated.
- Next, AxelChat will send a message in the format:
{ "data": { "app_name": "AxelChat", "app_version": "0.37.3", "client_uuid": "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", "services": [...] }, "type": "HELLO" }
The
services
field will display the client ID, which is assigned to the client by AxelChat.
The services
field stores information about the services currently supported by AxelChat.
- Next, AxelChat will send messages:
STATES_CHANGED
- Information about the status of services:
{
"data": {
"services": [
{
"connection_state": "connecting",
"enabled": true,
"type_id": "youtube",
"viewers": 11
},
{
"connection_state": "not_connected",
"enabled": false,
"type_id": "twitch",
"viewers": 13
}
],
"viewers": 24
},
"type": "STATES_CHANGED"
}
NEW_MESSAGES_RECEIVED
, MESSAGES_CHANGED
- New messages received or changed existing messages:
{
"data": {
"messages": [
{
"author": {
"avatar": "<avatar_url>",
"color": "",
"customBackgroundColor": "",
"id": "<user_id>",
"leftBadges": [],
"name": "Alex",
"pageUrl": "<user_page_url>",
"rightBadges": [],
"serviceId": "youtube"
},
"contents": [
{
"data": {
"text": "Hello, I'm Axel"
},
"type": "text"
}
],
"customAuthorAvatarUrl": "",
"customAuthorName": "",
"deleted": false,
"destination": [],
"forcedColors": {},
"id": "<message_id>",
"publishedAt": "2024-08-04T16:18:02.954",
"receivedAt": "2024-08-04T16:19:18.548",
"extra": {}
},
{
"author": {
"avatar": "<avatar_url>",
"color": "",
"customBackgroundColor": "",
"id": "<user_id>",
"leftBadges": [],
"name": "Inn",
"pageUrl": "<user_page_url>",
"rightBadges": [],
"serviceId": "youtube"
},
"contents": [
{
"data": {
"text": "See this image "
},
"type": "text"
},
{
"data": {
"url": "https://fonts.gstatic.com/s/e/notoemoji/15.1/1f44c_1f3fc/72.png"
},
"type": "image"
}
],
"customAuthorAvatarUrl": "",
"customAuthorName": "",
"deleted": false,
"destination": [],
"forcedColors": {},
"id": "<message_id>",
"publishedAt": "2024-08-04T16:18:04.069",
"receivedAt": "2024-08-04T16:19:18.548",
"extra": {}
}
]
},
"type": "NEW_MESSAGES_RECEIVED"
}
CLEAR_MESSAGES
- Cleared all messages
{
"data": null,
"type": "CLEAR_MESSAGES"
}
Notification of changes
New message types may appear in future updates of AxelChat. Also, existing message types may be changed, usually by adding new data to the message object. Stay tuned for updates
Output to files
This method is considered obsolete and may no longer be supported in the future.
To connect to AxelChat using file reading, follow these steps:
- Launch AxelChat
- In the section
Settings->Output to files
enable output to ini-files - The specified folder will store files that contain various information from AxelChat. These files periodically update their contents and your software must periodically read and parse these files to receive up-to-date information from AxelChat