Skip to content

Overview

Our chat message API returns bits of stats as complete, pre-built messages. Messages are build using data from one of our data sources and predefined templates.

Message templates#

After we fetch the required data from a source, we construct a messages using the data and a predefined template. A template contains some static text as well as placeholders for the data. Here is what a simple template looks like on our end: {{{name}}} has died {{value}} times so far this round. However, you never interact with the templates directly, as all you need you to do is request a message based on a template via the API.

Some templates are generic, meaning that they apply to a number of different objects of the same type. For example, one generic template can be used to build messages for any weapon of a game. Another generic template can cover all vehicles, characters or similar. In order to use a generic template, you need to provide both the name of the template and the identifier of an object (the name of a gun for example).

Take a look at each game to find out what templates we offer for each one.

API location#

The chat message API is available at https://api.statbits.io/chatmsg/.

Message endpoints#

Even though message endpoints may differ slightly between games, they all follow the same general structure: https://api.statbits.io/chatmsg/{{game}}/{{source}}/{{platform}}/{{type}}/{{identifiers}}/{{template}}. If, for example, you want to get the current, in-round summary for the Battlefield 2 player MrRubert, you would use the following values for the placeholders:

Parameter Value
game bf2
source live
platform pc
type players
identifiers MrRubert (player name)
template summary

Putting the URL structure and the values together we get https://api.statbits.io/chatmsg/bf2/live/pc/players/MrRubert/summary, which would return MrRubert currently has 35 points, 11 kills, died 6 times and is playing with 42ms ping.

Generic template endpoints#

For generic templates, the object name needs to be provided in addition to the name of the generic template: https://api.statbits.io/chatmsg/{{game}}/{{source}}/{{platform}}/{{type}}/{{identifiers}}/{{template}}/{{object}}. To get a summary of the P90 weapon stats for a Battlefield 4 player, you would need to supply the following values:

Parameter Value
game bf4
source stats
platform pc
type players
identifiers 1547476679:aK-SpeedyHS (player id:player name)
template weapon-summary
object p90

The final URL for this example: https://api.statbits.io/chatmsg/bf4/stats/pc/players/1547476679:aK-SpeedyHS/weapon-summary/p90. Sending the request to that URL would return Using the P90, aK-SpeedyHS killed 232 enemies with 22.73% accuracy (5,214 shots fired, 1,185 shots hit, 50 headshots).

Error messages#

The chatmessage API always returns runtime error messages as plain text.

Query parameters#

The following optional query parameters can be used to customize the API response.

Parameter Type Description
currentGame string Game you are currently streaming. If provided, this is validated against the game you are requesting live data from. If the values don't match, we will return an error message.
errMsg string If provided, this message will be used in case of runtime errors (source offline, player not online etc.)
forceOk boolean If set to a true-ish value, the API will return 200/OK even in case of an error
msgName string If provided, this name will be used in the message instead of the player name
lang string Language the message should be returned in, must be the ISO 639-1 code of one of the supported languages