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.
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)
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?
App token cannot be refreshed, you will have to request a new one
You can store when your token will expire and refresh it ask a new one at that point.