Someone has asked me to implement a live sub point tracker for a subathon they’re planning to do. I can do the coding, but I want to make sure my plan is the best way to go about this. Note that I’m looking for sub points, not total sub count.
To get the initial count, I’ll have to call the get broadcaster subscriptions endpoint and loop through all of them. I then want to listen to the pubsub topic for channel subscriptions to catch new ones. A resub may or may not count toward sub points because of the grace period after it expires when it’ll still show as a resub, so to get around this I’ll have to cache the list of subscribers from the API call and check if the resub user is in that list. If they are, I won’t increment points.
I’ll have to call the endpoint and recalculate manually on a timer every 10 minutes or so because there’s no live way to catch when someone’s subscription is canceled, and also because I don’t know if the pubsub topic fires when someone resubs but chooses not to share it with chat.
I looked at the webhook topic for this, and it’s worded as though it fires when someone unsubscribes, but there’s no example payload for that. I’m also not sure how delayed those webhook calls are, so I don’t know if it would be appropriate for a live counter on stream.
Does this plan sound good? Any advice would be appreciated!