title: Twitch API Integration into Discord Bot - More efficient way?
body: <p>I am currently writing a Discord Bot in C#. I have most the bot done but for this next update I am wanting to add on the capability of checking if the Streamer has Gone live. Currently I am polling the Twitch API and Pulling the JSON File that it has and checking whether or not the JSON Stream Object is Null or Not. But this takes 3-5 min after the streamer to go live before it finally sees that Stream is not Null even though I poll the JSON every 5 seconds. Is there anyway to do this more efficiently? My code is Below:</p>
  
  <pre><code>       private const string Url = "https://api.twitch.tv/kraken/streams/streamer";
          var request = (HttpWebRequest)WebRequest.Create(Url);
  
          request.Method = "Get";
          request.Timeout = 12000;
          request.ContentType = "application/vnd.twitchtv.v5+json";
          request.Headers.Add("Client-ID", "ID");
  
          using (var s = request.GetResponse().GetResponseStream())
          {
              using (var sr = new System.IO.StreamReader(s))
              {
  
                  var jsonObject = JObject.Parse(sr.ReadToEnd());
                  var jsonStream = jsonObject["stream"];
  
                  // twitch channel is online if stream is not null.
                  LastTwitchStatus = jsonStream.Type != JTokenType.Null;
              }
          }
  </code></pre>