Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twitch integration uses excessive API requests #128866

Open
qwell opened this issue Oct 21, 2024 · 5 comments
Open

Twitch integration uses excessive API requests #128866

qwell opened this issue Oct 21, 2024 · 5 comments
Assignees

Comments

@qwell
Copy link
Contributor

qwell commented Oct 21, 2024

The problem

Many of the Helix API requests (e.g. get-streams, get-channel-followers, and get-followed-channels) offer pagination. I follow about 120 channels, which ends up being somewhere in the area of 500 API requests and takes about 3 minutes to update every channel.

For me, the number of API requests could be reduced by 75% by adding pagination. Further, if usage of check-user-subscription (no pagination available) became a config option, the number of API requests would be reduced to only about 10.

What version of Home Assistant Core has the issue?

core-2024.10.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

twitch

@qwell
Copy link
Contributor Author

qwell commented Oct 21, 2024

I'm wrong about get_streams; it would need to switch to get_followed_streams to get pagination (get_streams works on all streams on the platform and removing broadcaster_id there would just be a massive list).

I took a crack at this, but async Python breaks my brain and I gave up. Taking get_channel_followers and get_followed_streams out of the self.users loop did seem to work though -- you just need to remove channel.id and change/remove the first param.

@joostlek
Copy link
Member

I mean I am happy to help you out where needed. I use Twitch not that often so it's not that high on my priority list (which is long), so if I can help you out with that, that would be awesome

@home-assistant
Copy link

@qwell
Copy link
Contributor Author

qwell commented Oct 21, 2024 via email

@joostlek
Copy link
Member

Also be aware, something got merged that centralizes the api calls, so there already is a difference between 2024.10 and dev. It probably won't be fabulous, since we need to store all the data in 1 entity (which I want to split up, hence I centralized the data fetching)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants