[Python]I can't make !uptime command for my bot

If you haven’t already, I would change your password if you put it on a public paste site – And probably regenerate your applications secret key to be safe. (Anybody who subscribes to emails from twitch dev forums still has access to the password.)

Re: The original post,

If the stream is offline it returns a null object, not a stream object (you will also get a null object if you had a web exception, such as not passing a ClientID]. You need to check if your api object is null first, and if not, THEN do your checks.

I would recommend also catching web exceptions (whatever that looks like in python) and printing the http status code + error message if you get one.

Re: @BarryCarlyon 's point, you need to either send your ClientID as a header value in your api request, or as a ?client_id=xxxxxx at the end of the url.