Rate Limiting of twitch API

Hello, I read the documentation but i’m not sure I understand, I building a webapp that need to do a lot of call to twitch API, I need to understand the limit rate :

  • One user with acces_token can do 800 request per minute
  • All the app with access_token per user can do 800 request per minute

Thanks by advance :slight_smile:

App Access tokens don’t have a “user context” and can’t be issued to users

App Access tokens represent server 2 server requests for your ClientID

Otherwise yes this is correct

Thanks a lot, so to confirm : my app will be limited if I do 800 request per minute, all users combined !

https://id.twitch.tv/oauth2/token?client_id=' + process.env.CLIENT_ID + '&client_secret=nyjkxuqdnz5up6qmuw4bkflet865ix&grant_type=client_credentials

And deserve a token to each user don’t help to have more request ?

An app access token has 800 requests.

Each user token has 800 requests.

So you have

  • app access token 800 requests
  • freds user token 800 requests
  • bobs user token 800 requests
  • sallys users token 800 requests

Each user gets their own pool since in theory you’d be using the users own token to access priviledged data like subscribers

Nice , It’s means this call can be call 800 time per minutes for each user beacause I use Client ID and user token ?

const fetch = require('node-fetch');

module.exports = function(req) {

    //Init constant
    const url = req[0];
    const twitch_access_token = req[1];

    return new Promise(resolve => {

        //Fetch twitch API
        fetch(url, {
            method: 'GET',
            headers: {
                'Client-ID': process.env.CLIENT_ID,
                'Authorization': 'Bearer ' + twitch_access_token
            .then(res => res.json())
            .then(function (res) {

                //Return result as promise

Not sure what you are asking here.

Either way, just monitor the response headers for the current rate limit and respond accordingly

Sorry i misspoke, my question was :

When I call the API with this in header 'Authorization': 'Bearer ', is this considered as an user request?


Since “auth” header and “bearer” is used for both App Access and user tokens.

The user (if any) that the token represents ID’s what Rate limit “pool” to use.

So token foo could be an app access token and token bar has bob’s user_id attached as it’s bob’s user token.

So it is a “user request” if the token belongs to a user
Is a server to server request if the token doesn’t belong to a user as it’s of type app access

Ok, so i need the user to connect with twitch account to have user tokens and do 800 call per user because right now i’m usign a client credentials auth :frowning:

That’s right ?

That would seem the case.

If you are hitting the rate limit what are you doing?
There are a number of ways/solutions to solve this problem without having to get users to authentication to “bypass” the rate limit.

Which seems to be the case?

I’m building a web app to random streamer, and you can call an array of streamer with category and lang and randomize like omegle or other website, the problem : I need sometimes with some filter call 50000 streams 100 by 100 and if I have, imagine, 500 user on app, I will be rate limitate

Then you need to employ caching on your server.

And attempt to avoid looking up a user you recently looked up.

Why lookup the user_id/information of a streamer called fred. if you got that 5 minutes ago?

So the more data you can temporarily keep on the server to refer to, the less API calls you need, and avoids a double API call round trip delay.

As your normally you go

Front end → Backend → API

If you can instead go

Front End → backend → my cache → maybe API

Then it’s quicker for the end user as you stop at the “my cache” and then load more quickly

Alertantively: you ask the user to login with Twitch, and then only use the users own token for the API calls the user is making via your website/tool

The current way I m using api can’t cache information, so i will make the last suggest

  • Call all stream by game and lang, in a while loop to store all data in an array
  • Simultaneously when the first 100 are call alow user to random streamers with this array
  • Call the curent stream randomise by the user all minutes to update viewer count and other things
  • Call the user endpoint to get profil picture

The first point is recall on each filter change

The other point are call on each “randomise”

Thanks a lot with an account system it will work better :slight_smile:

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