Hi everyone, I’m creating a new app where people will be able to show their latest followers, bits donators, and subscribers in real-time.
For the real-time data, I’m using EventSub, it’s working perfectly and I have no issue with it at all.
My problem is to fetch the initial data when the application is loaded. For that, I’m using the following endpoints:
-
Follower:
/users/follows?to_id=USER_ID&first=1
(Working fine for my purposes!) -
Bits:
/bits/leaderboard?period=day&count=1
(I couldn’t test it because my account is not partnered)
The subscribers API is the most problematic one for me because, we have Helix and Kraken (deprecated). However, Helix doesn’t attend to my needs and I think the endpoint is buggy. Why:
Using the endpoint as GET 'https://api.twitch.tv/helix/subscriptions?broadcaster_id=USER_ID'
:
- It returns the default users, but the order that the result comes is totally random, sometimes the first user on the list is not the same.
- The cursor is always present, even if I have only a few subscribers or less than the
first
parameter. The documentation says: If this is empty, you are at the last page. Clearly, I was in the last page and the cursor was still there.
With this issue, I started using the parameter ?first=1
, the problem was solved, the result was always the same in this case. But this doesn’t solve my scenario, this is the first subscriber, I need the latest one or the most recent one. Since the endpoint pagination cursor seems buggy, I’m not quite sure what to do.
With this in mind, I started using the Kraken API, I know it’s deprecated but it is what attend my needs, so I’m using it like this: /channels/CHANNEL_ID/subscriptions?limit=1&direction=desc
Because we have the direction
parameter available, I can just get the latest subscriber and that’s it.
So based on my problem above, is there a better way to get the most recent events when I load the application? The real-time integration is working fine, my problem is only when I need to show the first data.
Thanks!