Q:

Is there a way to reload an API every X seconds/minutes

So I'm working on a tkinter gui for my raspberry pi 3 and i've some information coming through an API call, the thing is, i need to restart the system before it will update the api. I would like to have the API update automatically every X seconds or X minutes.
I hope you understand what i'm trying to tell you. Here is the code for the API call 
    r2 = requests.get(' http://api.adviceslip.com/advice')
    advice_result= r2.json()

A:

import threading
import requests

def reloadapi():
    threading.Timer(5.0, reloadapi).start()
    r2 = requests.get(' http://api.adviceslip.com/advice')
    advice_result= r2.json()

reloadapi()

Here, your api is reloaded in every 5 seconds

