Been searching for this a few hours now, and it seems hard for me to wrap my head around.
What I want is to obtain the subscribers to my own channel. I have a channel_id, client_id, client_secret and all other info needed.
It’ll only be for my own channel! I want my PHP script to automatically authorize this request (with any credentials needed) and then return to me a response with subscriptions.
I use the ‘new API’, but I’m willing and able to use the v5 one, I don’t really care at this point ;-).
Just: subscriptions, no manual actions by me, all automated through PHP.
I already know how to obtain an ‘app access token’, but that doesn’t give me the right to obtain subscriptions. So what I need is to obtain a ‘user access token’. Everything from there on won’t be a problem!
That’ll take you through the auth process to create a User Access Token, and a Refresh Token. This step can’t be automated, you have to go through this process once so that you can grant your app the specific permissions you need, which in this case will be the channel:read:subscriptions scope to grant you access the list of subscribers to your channel.
Once you’ve got the tokens, you can automatically refresh them as they expire so from this point on you can automate it all, it’s just that initial auth step that requires the user to actually go through Twitch to grant you the permission to access the data.
I didn’t get that ‘you have to authorize manually ONCE!’ part.
After doing this, I can indeed fetch stuff!!
Still need to figure out the refreshing of the token, but I’m sure I’ll manage.
Pfff… this took me way too long. But thanks to your help and explenation things are a lot clearer now!
Refreshing is a similar request to the code to token exchange.
You can use
To validate/check your token and decide if you need to renew. But I have code that does sub fetching every three hours, (and a User token is usually good for four hours), so I always refresh before I start my run(s)
OK, so I got it working with Kraken…
Works nice too, image, name, etc.
Just the ‘is_gift’ is broken… it’s always False, even if the sub was gifted.
So I thought, let’s give Helix a spin.
Works too, except that one doesn’t give me ‘created_at’ or user-image.
Who thought that was a good idea? To not include the datetime a sub was created / started?!
With every sub the ‘broadcaster id’ and ‘broadcaster name’ are included… but not when it was created…
Yes… the above is a bit salty… but I feel that implementing things with this API is a struggle.
Documentation is dubious, there’s multiple ways to do things, but every way has a disadvantage, somehow.
Is there any way, to get my own subscriptions, with Helix (because, new api) including all relevant data. Especially date-created (of the sub), the type of sub, the user info (incl image url) and if it was gifted?
Date Created: no. Since the date created in kraken is actually the date that the current payment period started, it’s not the number of cumulative months the sub is. it’s the streak. Helix doesn’t (currently) have tenure data but it is something a lot of us have asked for.
Take the user_id and look them up on the users API
Any way, to get any sort of datetime that is related to the sub?!
I mean, I want to show resubs, subs, gifted subs, etc but WITHIN a timeframe.
Kraken does it! So the data is there!
Thnx for the tip about the user_info.
It’s just again such a hassle, since this data was included in the first initital call when using Kraken.
Now, I need to fetch items for every sub (perhaps in bulk, but still) after retreiving this list of subscriptions.
If it’s the only way, it’s the only way, but… really???
And works as a normal helix endpoint, but the documentation is missing,
But call
https://api.twitch.tv/helix/subscriptions/events
Kraken is a totally different API and I believe works in a totally (and perhaps no longer fully working) different way to Helix, the data models are different hence whats returned is different
So if you are trying to do “all the subs from today” your best bet is to collect in real time using PubSub or Chat.
Thanks so much for all your replies. They’re very thorough. I appreciate it a lot!
But I have to say, this stuff is broken!
In many posts I read the remark ‘but helix is just different from kraken’ but that is in no way a reason ;-).
Twitch knows exactly when a sub initially started, when it was paid for, when it expires and when it was prolonged. No data-model stands in the way of that.
It’s just a different look on things by different people developing the API’s. And that’s what bothers me somewhat. Getting datetimes with each sub is probably what a lot of people are looking for (I’m generalising now, I know).
Storing this data with webhooks is an option (I do it through / with Streamlabs already), but that also doesn’t excuse the fact that it should simply be in this API.
Let us close this issue ;-).
Thanks again for all your help!! I hope you have a nice weekend.
To clarify: We’ve never ever had any accurate subscriber tenure data in any API
(As previously stated kraken’s date_create is not “accurate” for mathing months a sub has been a sub for. It’s the start of the current payment period).
So we have always been waiting for twitch to put accurate sub tenure data into the API (kraken or helix)