I am attempting to create the backend of a Twitch Extension that will search for all other users streaming the same game. The only way to get the Category with which to compare games is if the channel in question is live. This is fine, as the extension should will only be working whenever the stream goes live.
My issue is that I do not know how I can determine whether or not the user of the extension has gone online.
public static async Task<string> GetStreamAsync()
{
string product = "";
List<Stream> finalProduct = new List<Stream>();
var response = await _httpClient.GetAsync("https://api.twitch.tv/helix/streams?user_login=Ninja");
if (response.IsSuccessStatusCode)
{
product = await response.Content.ReadAsStringAsync();
var streamToRelate = JsonConvert.DeserializeObject<RootStream>(product);
finalProduct = await GetAllRelatedChannels(streamToRelate.Data.FirstOrDefault());
}
return product;
}
As you can see, I've hard coded a stream that I knew was online at the time (Ninja). This data was returned perfectly fine, but the next step is to pass a string into this function with which to search. How could I go about getting the "User" of the extension at runtime? If I am completely off-base, and am missing certain concepts, please let me know as well and I will do further research if necessary.