r/PythonProjects2 • • Feb 13 '22

[P] Moderate Made this twitter bot using python that tweets out streams with 0 viewers! I love talking to people with 0 viewers, seeing them light up makes my day. Hoping this would spread that joy!

https://twitter.com/no_viewers
79 Upvotes

10 comments sorted by

View all comments

2

u/Whatupcraig Feb 14 '22

Mind posting the code? I’d love to see how you interacted with twitch.

0

u/vvinvardhan Feb 14 '22

umm, I don't wanna post all the code! This could be a great learning opportunity for you!

Twitch has a robust API setup which you can use! These are the API endpoints I ended up using. This is a good place to start

#for access token 
f"https://id.twitch.tv/oauth2/token?client_id={twitch_client_id}&client_secret={twitch_client_secret}&grant_type=client_credentials"

#getting game_id from a query
f"https://api.twitch.tv/helix/search/categories?query={gamehere}"

#getting english language streams in batches of 100
f"https://api.twitch.tv/helix/streams?game_id={game_id}&first=100&language=en"

#and you can paginate using the Cursor provided in the Pagination part of the json data