Twitch API Bugged...?

2 days ago I started noticing this problem, where the API will return really random stats for a channel. This has been screwing with my site, and it’s becoming a pain in the ass…

http://i.imgur.com X6MbaD4.png (put a slash before the X, I can’t put image links)

Here is an example. The image is a screenshot of how they look in our database at the moment. Take a look at their Twitch page. First off, the haven’t ever streamed (so why does it say they were playing HearthStone). They have 0 views, and 0 followers…

The viewers, followers and views are all taken directly from the Twitch API and stored in our database. So the numbers shown are a direct result of what Twitch’s API has returned (or so I’m guessing, since there is nothing in between the API call and the database save).

Again, this only started happening 2 days ago. I’ve had this happen to about 20 different streams so far, and I can’t find anything linking them to each other (a reason as to why this is happening). Not all streams are like this, just a few random ones.

http://www.manabot.tv/streamers/

You can view this page to see some streamers, and the screwed up stats (page constantly changing, so it may or may not display a bugged stream).

  • I have not changed any code on my end that would cause this issue.

  • There is nothing between the API call and the MySQL update query that would alter the information.

  • Does not appear to be any correlation between the bugged streams (as far as I can tell).

  • Started happening 2 days ago (Friday night).

  • The above is just an example. It does this for channels that have and haven’t streamed before, whether they are live or offline.

Please share what api call you’re making to help debug this further.

https://api.twitch.tv/kraken/streams?channel=[NAME]

(With the streamer’s name at the end)

Same issue for me: Inaccurate followers/views values from streams endpoint

http://i.imgur.com/ TddTnT3.png

Still doing it, fairly annoying.

All of those streams have the same views & followers data? That seems suspiciously like a bug in your application code. Is it open source so I can take a peek?

I haven’t seen any indication that our API is reporting terribly wrong numbers on a consistent basis. Occassionally we’ll have blips where we report 0 views/followers, or serve stale data, but that’s very rare and shouldn’t be happening on such a widespread basis.

http://pastebin.com/FiYnXXiA

  • It grabs the API information of the streamer.
  • It decodes the JSON.
  • Will check if viewer count is set, if not, it will set it to 0.
  • Updates the database with the viewer count.

There is a bit more code, I just removed a lot of it (same thing, dif values). As you can see though, I don’t ever edit the value.

You currently have a few streams marked as “live” on your site that aren’t live. All of their data matches the current top stream - Riotgames. This, plus the code you shared, makes me think that in some cases $stream_info['name'] is blank, causing your query to our API to return not one stream object, but all available streams. Then you blindly grab the top stream and run your update query that blindly the database… potentially hitting every row since you don’t escape your variables?

If I had unredacted code I could MAYBE try to guess at the bug, but I’ve very confident that the issue is either in how you’re calling our API, how you’re updating the database, or both. Possible values of $stream_info['name'] would also help.

Hmmm, not sure how that’s possible. I’ll add some debug stuff tonight and let you know what I find.

Also, here is the full script of that function if you want to look it over.

http://pastebin.com/x94HeLSi

Did you see my reply above? Inaccurate followers/views values from streams endpoint - API - Twitch Developer Forums

The data in in the growth trend is a snapshot of the channel at midnight PST.

Here is a log of what I saw during LIRIKs issue on my post


There looks like there was another bad data point last night

Dug deeper into this, and it looks like this could be related to instances where the API is not returning a followers and views property on the channel. Is this intended behavior? Under what conditions does the API omit that data?

"channel": {
  "_id": 14518599,
  "name": "afflictedstudio",
  "created_at": "2010-08-10T17:46:05Z",
  "updated_at": "2015-04-27T19:18:26Z",
  "_links": {
    "self": "https://api.twitch.tv/kraken/users/afflictedstudio"
  },
  "display_name": "Afflictedstudio",
  "logo": "http://static-cdn.jtvnw.net/jtv_user_pictures/afflictedstudio-profile_image-25f675af425c8228-300x300.png",
  "bio": "Afflicted Studios has been streaming for over 4 years. The original channel (AfflictedStudios) was established in 2009 at Justin.tv. The channel is slowly growing and maintaining loyal fans. Thank you all for your support!",
  "type": "user"
}

*Looks like a user is being returned instead of a channel. The incorrect values seem to be a side effect of me not properly accounting for the missing values. Maybe you are having the same issue @ManaPot

I can report the same issue as stream object is sometimes missing some values or . for our software to work properly we then have to make a new API call to get the correct data which should be a problem for future rate limits.

Will this be fixed, twitch?

@betz0r,

According to @night

This is a bug that I have already reported. The problem you are experiencing is that the user object is being returned instead of the channel object for the channel requested. Unfortunately this appears to be a caching bug, and as far as I’m aware there’s underlying technical challenges which prevent its immediate possibility of being fixed.

See this post:

I read it and can confirm channel object is often given instead of demanded stream object.

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