Client-side requests limitation when using JavaScript?

Hello! I’m new developer using Twitch API and this is my first post :slight_smile: .
I’m using JavaScript to develop a userscript that periodically checks the streamer’s online status on the client side.

Llike this.

var arr = [‘name1’,‘name2’];
// Streamer names are user input values of DOM form.
// Therefore, each user’s request may be different.

$(arr).each(function(i){
$.ajax({
url:“https://api.twitch.tv/kraken/streams/” + arr[i] +"?callback=?",
type: ‘GET’,
contentType: ‘application/json’,
dataType:‘json’,
headers: {
‘Client-ID’: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
},
success:function(channel) {

I found an example. The big difference is whether or not to refresh every a minute.

In my case, about 50~100+ users will check the online status, name, thumbnail, and title of 15+ streamers every 1~3(?) minute on the client side. The results are cached in local cookie, so the users don’t make another request within refresh interval.

I have already written the code and confirmed that it works fine, but I have a question.
Can these requests be a problem? (So many requests? So many client-side users? Very short interval requests?)
I’ve seen a lot of topics, but I could not be sure of the limitations of the client-side request. I wonder whether the level that this situation could be a problem.

If there are no problems, I need to determine the maximum number of streamers and the minimum refresh interval minute to check the online status.
It would be nice if someone could give me the proper number. Thank you!

Your current approach would be quite excessive, for example you seem to be making 1 API call per streamer you are looking for the stream object of? If you are expecting users to be looking up 15 streamers as a time, then that is 15 API calls per user, when you could just do it in 1 request per user using a comma separated list of streamers.

From what I’ve always understood here, an app should try not to exceed 1 API request/sec. I haven’t seen any hard figures on limits, but that is reasonable and for most use cases that is sufficient unless the app is poorly designed.

I also hope you are aware that by doing all of this client-side there will be the potential for a lot of duplicate API calls, with multiple users looking for the same stream but each having to make their own API call regardless of if another user made the exact same request moments earlier, which is a very inefficient user of the API and could limit your apps use.

I will use a comma in my code! :smile:

At first I thought. ‘Do I need to make a cache server to reduce the API load?’
Because this is my first use of the Twitch API. :sweat_smile: (With these concerns, I have not released the code yet.)

So I saw Chrome and Firefox extension code with more than 100 users.
However, most of the code did not use a cache server.
So I wondered if there was a standard.

But thanks to you, some questions have been solved.
Thanks for your reply!

Some use a caching server, some don’t. You may be able to get better response time and usage tracking using a caching server, but it’s not required.

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