When I do a GET request to https://api.twitch.tv/kraken/streams/<channel ID> the follower count is off. Seems like the most recent followers are not updating like it should be. Viewers update live but the followers are not. Is there a way this can be fixed? It appears that the follower count updates every 5 - 10 minutes or so but I would like a live update.
API endpoints will always be a little behind by about 30 seconds to even longer (depending on load I believe, few minutes isn’t that uncommon I think.)
If you are building a follower notification system, then a common practice is, when an API call is done and new followers found, announce them evenly between the time the call is done till the time the next call is done.
I also tried on my end to see if there was a difference between pulling followers via /streams/ or /channels/ but both update at about the same time.
Yeah I get that but there is a really long delay before it updates. Sometime even up to 15 minutes. I have tried both /streams/ and /channels/. The /channels/ request seem to be closer to the correct number but still has a 10-15 minute delay.
The Twitch API uses a caching system that is only updated every few minutes. If you make requests within that update period, certain fields and endpoints won’t change even though you make a new request.
There is kind of a “hacky” way around this though to trick the API into giving you a brand new request instead of accessing the cache every time. All you need to do is add a query parameter with a random value every time a request is made, so something to the tune of this:
public new RestRequest Request(string endpoint, Method method)
RestRequest request = new RestRequest(endpoint, method);
request.AddHeader("Authorization", "OAuth " + g_oauth_token);