Viewer Data Aggregation

Too Many Viewers

Your extension will (hopefully) get used by lots of viewers. Lots and lots of viewers. Like, several hundreds of thousands or even millions of viewers. Congratulations!

However, this does present a problem when trying to collect actions from all those viewers and do something meaningful with them. If you try and send a message every time a viewer clicks a button, for example, you would quickly run into rate limits. If you tried to notify the broadcaster every time a viewer chooses a poll option, the broadcaster would get pinged a couple thousand times a second.

Aggregation to the Rescue

To make user data accessible to other users and/or the broadcaster we provide several handy data aggregation methods. These methods cover some of the most common and useful scenarios you may need. Our servers handle the problem of accepting input from millions of users all at once and making the results available when you need them.

All of the aggregation methods take a namespace id that identifies that collection of data. This allows you to have several types of data sources occurring at once with no overlap.

In addition, all data your extension generates is limited to your extension and optionally to the channel on which the viewer action occurred. This means no other extensions will be able to access your data, and if you’d like, channels running your extension cannot access each other’s data either.

The namespace_id you provide has some restrictions: lowercase letters, numbers and underscores only. Each namespace defines its own data set, however you may use the same namespace with different aggregation methods and not have data cross-contamination.

The available aggregations methods are:

Accumulation

Accumulation is the simplest form of aggregation. Using this method, the server simply timestamps and concatenates all JSON blobs sent to it.

More details can be found in the Accumulate endpoint documentation.

Voting

Voting is a convenience endpoint for letting viewers “vote” on a poll. Depending on the values you send, the poll can sum the sent values, classify the most popular option or provide statistics based on the submitted values.

More details can be found in the Vote endpoint documentation.

Ranking

The ranking endpoints allow you to send arbitrary per-user keys to the server and request a ranked response of the most popular. The keys can be any string value.

More details can be found in the Rank endpoint documentation.

Trivia

The trivia system is similar to voting, however each question asked has a “correct” answer set by the extension administrator. This allows you to reward viewers for guessing correctly or show a leaderboard of the best guessers. Currently trivia questions are only available extension-wide and must be created and controlled by an extension admin.

More details can be found in the Trivia endpoint documentation.