Run custom PHP function in WordPress once a day

I am writing a custom php code that get some data via API request in WordPress and attach the function to function.php. The problem is the function run whenever I reload the webpage. I want it to run only once in 24 hrs i.e I want it to make api request once a day. How can I do that. Can someone please give me some idea.