There’s no way to get historical data through the API.
If you want to get that data then you would need to keep track of it in real-time, such as by periodically polling the Get Streams endpoint and then calculating their hours streamed, viewer count, and things of that nature yourself.
For some data, such as sub count, you would need the broadcaster to grant you permissions to access their subscribers list, otherwise you would be limited to guessing sub counts based on subscription messages in chat but this results in VASTLY inaccurate sub counts which is why sites like twitchtracker which guess sub counts are not particularly useful.
Do you have any idea of how to get this kind of data in real time and recording it? Since Twitch doesn’t provide it, then how could we calculate on our own?
Im doing a website for a streamer and the idea was to do a dash with this data, so Idk what to do since twitch doesnt provide what I need or how calculate this on my own
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.