简体   繁体   中英

How can I check if Someone is Live on twitch with the Twitch api python

I want to have a discord bot that posts in my server when I'm live but everyone one I've used does not work so I decided to make my own. I wanna use the twitch Api to do it and in python but I cant find any tutorials that work or any recent ones. Does anyone know how I can check if a streamer is live with the twitch api python?

If you aren't already familiar with the Twitch API it's recommended that you review their documentation before getting started as there will be some steps to take to get Auth when requesting the information for any Twitch account using the API.

https://dev.twitch.tv/docs/api/

Once you've got your tokens and authentication setup detecting the online status of your stream can be done be trying to read the streams end-point.

https://dev.twitch.tv/docs/api/reference#get-streams

If you're offline that end-point will return blank and when you're online it will return with the information relating to your stream.

You can set your script to check if the end-point is returning any values or not and have it send an online message if you're online or do nothing when you're not.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM