Best way to update User Subscription status?

My company is currently working on a game and we have the need to check users Subsciption status to our own channel to update it in our database to give an ingame item only if the user is subscribed, and remove it when he’s not anymore.
The current workflow I am currently using is:
Users API part: The user links his twitch account with our own account system and our API checks if he is currently Subscribed, if he is, he’s given the item.
Then, we have a worker that runs every 6 horurs, and get all the subscribers of the channel, check if our users are still Subscribed or not or if they have subscribed in the meantime.

The problem here, is that’s i’m not sure it’s the best solution to do that.
I’m in need to keep the token refreshed (the token on the part of the worker) to check each time if the users are still subscribed.
Plus, it’s a very heavy operation on the Datas managed side (I have to pull all the user’s from the DB that have linked their account to check their current status).

Is this the only way to do that? Or is it another way?

Thanks for your answers.


What I do instead of getting a user token with subscriber status is:

  1. Get user to link their Twitch Account with $Mysite and only request the email scope.
  2. Using a channel_subscribers scoped token for the channel, I fetch all tge channel subscribers, every 3 hours.

This minimises the API requests, to number of subscribers to my channel/100 API requests instead of one API request per user.

Also means you don’t request the subscribers scope from the user, as some users, won’t want to grant you access to see ALL the channels they subscriber to.

  1. Once I got the list just DB compare :smiley:

Basically you don’t do a user -> channel check, but a channel -> user check. It’s better/less scary scopes on the API for the user, and way less API requests.

Hope that helps

That’s actually what I am doing with my worker (I construct a list of subscribers via the channel’s subscribers, and compare it to the users that have linked their accounts on the app).
I will do what you said on the user-part, by getting only the id of the user without checking directly if he is already subscribed, it seems a good idea for the scopes management.

But it answers to my question: it seems to be a good way to do it, thanks for your answer :slight_smile:

No probably glad to have helped!

I usually do the 3 hour or a daily sync, and add new subscribers via pubsub. To add a dash of realtime.

I forgot to add a note about pubsub adding new subs to be DB this morning

1 Like

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