Classic Chat API (CAPI)

On April 28, 2017, Blizzard announced an official API for the classic BNETv1 platform. This is intended to allow bots to easily connect to the platform using secure web sockets instead of needing to emulate the game protocols.

The latest revision of the CAPI protocol (V3) can be found in this document.

The chat API uses UTF-8 encoded JSON over secure websockets.

The connection endpoint is wss://connect-bot.classic.blizzard.com/v1/rpc/chat.

Instead of a username and password, the API requires a special key, which can be obtained by using the /register-bot command from your op or clan channel. The bot's name will be the username it was registered from, in lowercase and prefixed with [B].

Message Header

Messages sent to the server must contain a command, request_id, and payload. They will be returned with the same and optionally a status if an error occurred.

An example message will look like this:

{ 
    "command": "Botapichat.ConnectEventRequest",
    "request_id": 1,
    "payload": {
        "channel": "Op BNETDocs"
    }
}

Connection Status Checking (PING/PONG)

The server sends a websocket PING request every 10-15 seconds, which should be responded to immediately with the appropriate PONG. Many websocket libraries will do this automatically. Not responding to these requests will cause you to be disconnected.

Connection Sequence

To connect and start receiving messages, you must send and receive the following messages:

Chat Messages

Chat messages are received with the Botapichat.MessageEventRequest message containing user_id, message, and type.

Chat messages are sent with the Botapichat.SendMessageRequest command.

For example:

{
    "command": "Botapichat.SendMessageRequest",
    "request_id": 1,
    "payload": {
        "message": "Hello world!"
    }
}

Classic Command Equivalents

Here is a mapping of the classic slash-commands to their API equivalents:

Limitations

The chat API is in the Alpha state and so has limited functionality. How much of these limitations will be lifted is not known.

Known Bugs

| Edited: Davnit

Comments

no one has commented yet.