I’m working on a Twitch extension and I want to check if user is subscribed to the channel.
I know that the easiest solution is to use Subscription Support in monetization tab but that requires me to go through onboarding which will take sometime before being approved.
Could anyone describe step by step which keys, apis, routes do I need to implement in order to check whether user is subscribed to a channel?
Notes: Extension requires user ID permission, I make use of EBS
If you don’t/can’t use the Subscription status flag, then do what we did before that flag existed.
Call the subscribers API using an oAuth you obtained seperately from the broadcaster. Your front end sends the JWT to your EBS, your EBS parses out the UserID, then use the brodcasters oAuth to check the subscription status of the user.
How should I deal with rate limits? Let’s say that I want to authenticate 3000 users for the same channel while Helix allows for 800 requests per minute.
If I am understanding correctly, per user means per broadcasters token which I also pass into Authorization header to get the 800/min.
I was thinking about creating some sort of queue and instead of checking each ID individually, I would check 100 users let’s say each second and respond appropriately but I am clueless as to which npm package would be most appropriate for this task.
For an extension since the JWT has the current status, you can use that.
And only EBS check when the user performs an action, such as submitting data or triggering something that would be sent to the streamer
All Helix endpoints require a bearer so the 30 limit no longer exists
As you are an extension you can use an App Access Token/Server to Server token, so you don’t have to juggle multiple access keys, and you don’t have to get additional authentication from the broadcaster. Just generate and use an App Access Token for your extension
The rate is very burstable and forgiving you might find you don’t get close to the limit, depending on when/what/how you need to do the EBS check, a queue might work it might not.
Let’s assume that I have to handle large traffic nonetheless.
How should I deal with that?
Can You link me to any resource?
How should the queue be written to prevent getting errors?
What would be the best NPM package?
Cache what you can where you can, to avoid having to make calls
You can’t prevent errors, you have to handle errors.
Does a queue even work, if someone loads your extension they want a instant data response from your EBS, they don’t want to have to wait for your extension to run the queue. So does a queue even work?
“The best NPM package” to do what?
Generally I limit my packages to Express, got and database interaction, I avoid packages that wrap API’s for me, I usually don’t need or want that level of interruption to my code, but sometimes you don’t want to or shouldn’t reinvent the wheel.
But for Twitch, I don’t use any package, I just use Got for my HTTPS requests and a small module that handles app access token management and how I include that module/block of code varies by project.