Downtime of hosts for a specific month

Hi everyone,

I am using the API to extract monitoring data.
Is there a way of extracting the exact time a specific host was down for a specific month?
I have been trying this by tracking the “host_last_time_up”, however, due to the constant overwriting, my calculation is not good enough

Thanks in advance
Alex