Twitch Live Tracker
I integrated the Twitch API to develop a Python application. It notifies me when someone is live on Twitch and displays the live streamers in the app.
def notify_live_streamers():
import requests
client_id = 'your_client_id'
client_secret = 'your_client_secret'
token_url = 'https://id.twitch.tv/oauth2/token'
stream_url = 'https://api.twitch.tv/helix/streams'
# Get OAuth token
response = requests.post(token_url, data={
'client_id': client_id,
'client_secret': client_secret,
'grant_type': 'client_credentials'
})
access_token = response.json()['access_token']
# Get live streams
headers = {
'Client-ID': client_id,
'Authorization': f'Bearer {access_token}'
}
response = requests.get(stream_url, headers=headers)
streams = response.json()['data']
for stream in streams:
print(f"{stream['user_name']} is live with {stream['viewer_count']} viewers")
notify_live_streamers()