Getting total bits via API request instead of PubSub

So currently the only way to find the total number of bits that a user has given to a channel is by listening via PubSub and getting an event.

Was wondering if there were plans to add it anywhere else such as an endpoint for channels to get a list of those who’ve given bits and how much, similarly to how you can get subscribers and their level for a channel?

The only way to access a user’s bit information via an API instead of PubSub is through this unsupported API with this URL format:

https://api.twitch.tv/bits/balance/{{user id}}?channel={{channel id}}

But this is only accessible with a cookie called “persistent” in the format of “user id:unknown:unknown” (and URI encoded). You can get your own by opening the developer console in your browser, opening it to the Network tab, and then load a Twitch page. You’ll need to defeat the scroll as there will be many requests and select the first one in the list. Once you click it you’ll get a new panel. Click the “Headers” tab and then look at the “Request Headers” section for “cookie:” and the big wall of text. These are your cookies. Read through the “cookie” header’s value and you’ll find a cookie labeled “persistent=…” – this is your “persistent” cookie that you can use.

Here’s an example request in cURL with a randomized cookie checking “Alca” (me) in ScufJumpn’s channel:

curl 'https://api.twitch.tv/bits/balance/7676884?channel=64284181' \
-H 'cookie: persistent=7676884%3A40vxx8f9jm4nu4j1smimc8ywu3%3A2ujx2xfhlon98gb5sad0bvz4k'

Here’s an example response:

{
    "balance": 0,
    "bundles": {
        "B017L2UX4C": true,
        "B018WMZKR0": true,
        "B018WMZN5E": true,
        "B018WMZSPY": true,
        "B018WMZYPI": true,
        "B01G4BISOS": true,
        "B01LZ42ZK9": false
    },
    "channel_total": 3004,
    "inventory_limit": 250000,
    "highest_entitled_badge": 1000
}

Unfortunately this is not practical to get other users’ data.

Further more, it’s a unsupported end point, so it can and will break at any time and isn’t really for 3rd party devs.

Currently the only way to get the total spend, is via the total_bits_used message key over pubsub, when someone cheers.

A subscribers level is under sub_plan in the subscribers API as outlined here Subscriptions Beta Changes

Further the method Alca mentions is only possible from a self perspective. The original request is for a channel to list bit totals for all users who’ve cheered in the channel.

As I said, “unfortunately this is not practical to get other users’ data.” You would have to update a DB with the PubSub channel-bits-events-v1.xxxx topic’s “total_bits_used” value.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.