Check if user is streaming

no

you use the client ID and client secret to generate a token

Since you are python, it’s just a requests.post to get a token

using the URL documented in what I linked to

before you try to get stream status, you’ll load a previously generated token, and check if it’s valid then make the call.

Only generate a new token if needed, reuse if you can

Edit: Something like

import requests

client_id = ''
client_secret = ''
streamer_name = ''

body = {
    'client_id': client_id,
    'client_secret': client_secret,
    "grant_type": 'client_credentials'
}
r = requests.post('https://id.twitch.tv/oauth2/token', body)

#data output
keys = r.json();

print(keys)

headers = {
    'Client-ID': client_id,
    'Authorization': 'Bearer ' + keys['access_token']
}

print(headers)

stream = requests.get('https://api.twitch.tv/helix/streams?user_login=' + streamer_name, headers=headers)

stream_data = stream.json();

print(stream_data);

My python is rusty but I got this to work.
And it doesn’t cover token reuse just generates a new one each time