qollers qollers - 1 month ago 11
Ajax Question

Twitch API stream search URL get total streams AJAX

I have an ajax function hitting the Twitch API to get up to 100 "runescape" streams.

$.ajax({
type: 'GET',
url: 'https://api.twitch.tv/kraken/search/streams?limit=100&offset=0&q=runescape',
headers: {'Client-ID': 'xxx'},
success: function(data) {
console.log(data);
}});


This returns the JSON response:
Object {_total: 95, _links: Object, streams: Array[82]}
.

But in my Twitch API URL, I've set
limit=100&offset=0
. I want the URL to return an object with
streams: Array[95]
to match the
_total: 95
. Because
total_: 95
is less than the
limit=100
, I thought I would be able to get all the streams into one
streams
array, but this isn't the case. Anybody familiar with the Twitch API? How come this isn't the case?

doc: https://dev.twitch.tv/docs/api/v3/streams#get-streams

Jim Jim
Answer

You better go with:

https://api.twitch.tv/kraken/streams?game=runescape&limit=100

Because as of the time of writing this it's a known issue they return less results then expected on the search endpoint

Comments