Extension getting 429s when calling Get Stream

We’re having an issue with getting 429s on our extension now that we’ve released it. Our extension checks for the state of the stream to see if the streamer is live to display the ability to make a bits transaction. When the streamer is offline and the extension is displayed as a panel, we inform the viewer that the streamer is offline.

We are using:
To check if live: https://api.twitch.tv/helix/streams?user_id=<user_id>
For authenticating the call: https://id.twitch.tv/oauth2/token?client_id=<id>&client_secret=<secret>&grant_type='client_credentials'
That is ran in our backend and we call our end point on the front end.

In the front end, what we are doing is while the api returns that the channel is offline we called the api again until it returned online in 0.5 second interval. After it returns online we stop the calling the api.

Does this look like it should run into issues with the Twitch API rate limiting?

The API is cached, you shouldn’t poll with the request faster than once per minute. Excessively requesting the same data can even return erroneous results where you may hit different cache servers and so get stale data after previously getting fresh data.

The ratelimit is 800 requests per minute, so if you’re getting a 429 response you’re sending requests faster than that. If you’re only requesting a single channel at a time, despite the Get Streams endpoint supporting up to 100 channels per request, then that will also likely result in you using significantly more requests than you should be on top of the excessive polling interval.

What you may want to do is just use EventSub on your server and subscribe to the stream.online and stream.offline types, then Twitch will send you notifications when the stream goes live or offline.