Hours the streamer is live is calcuatling by getting the start and end time of a stream
IE: when they appear in get streams (which will also give you the stream start time), and when they disappear from get streams (the approx end time)
Peak viewers, well you are checking get streams every 5 minutes or so, well then you have that data.
Hours watched: calulate that using the data you collected above.
This is all what Dist already told you.
If you are doing it for a single streamer and only that stream then you would utilise EventSub for Stream Start/End times.
As for viewers then you’d have to call the get streams endpoint peridicially to get the viewer count.
And then at stream end calculate the apporx hours watched from the data you collected for the stream.
Which is all done via Get Streams, like dist already told you.
Pretty much it’s basic maths/statistics really.