Ratelimit-limit has decreased out of blue


#1

Hi,

Recently I’ve increased your api calls on my application. Request are being made with token which has the limit of 800 requests per minute. Yesterday I set up api calls to be approximately on 800 level. Today in the morning I’ve observed 429 from your server. Further investigation showed ratelimit-limit[response header] had dropped from 800 to 30. I’ve checked it also manually, it is definitely ratelimit-limit.
This case is serious because “prod” server is also “down” by this limit.

Could you tell me why why this happened?


#2

If you haven’t been using an app or user token, you should expect a 30 request per minute rate limit.
If it was at 800 before, it was a problem on Twitch side.
The documentation gives you all the details: https://dev.twitch.tv/docs/api/guide#rate-limits

Solutions:

  • use an app token
  • optimize your API calls (800 a minute is A LOT, you can probably reduce it)

#3

And until recently, there was a bug where unauthenticated requests (ie just using Client ID) were getting the 800 limit.

It would appear this bug has now been resolved, and the posted limits are back in correct operation

Authentication Refill Rate Bucket Size
Bearer token is provided 800 points per minute, per user 800 points
Bearer token is not provided 30 points per minute 30 points

As linked above


#4

Is 800 points number of API call?


#5

800 points is 800 points

Currently each API request on Twitch requires spending 1 point.

(The distinction is important in case at some point some API requests require more than one point)

So currently to put it simply:

Yes


#6

I have used token to make request. Every GET has request property “Client-ID” set with token. ex. udwbhdlxi02t4sqnkg83ufx6gh4gta


#7

So you should have a rate limit of 30 if you only use the client ID :slight_smile:
Check https://dev.twitch.tv/docs/authentication for adding an app token


#8

Ok, I managed how to generate app token. Rate_limit has increased to 800. This token is valid for approximately 60 days.
I would like to implement auto-refreshing trigger in app, when token is no longer valid.
According to your documentation there is no problem with app token refreshing, however the refresh token is needed. Unfortunately, during getting app token Twitch server responses with just 3 elements -> [access_token, expires_in, token_type]. There is no refresh_token.

I’ve used post request https://id.twitch.tv/oauth2/token? with query params like client_id, client_secret, grant_type. How to get refresh token mentioned above?


#9

App token cannot be refreshed, you will have to request a new one :slight_smile:
You can store when your token will expire and refresh it ask a new one at that point.


#10

Could you elaborate?

I didn’t understand you actually. Each line denies the other.


#11

App Access Tokens, cannot be refreshed so you don’t get a refresh token when you make one.

When you app access token expires, make a new token.


#12

Ok, I got it. Thank you.