How to extract data from an API every hour in Python?
Assuming that example is working for you, trying to write the data every 3 seconds, you need to just change the scheduling to be

schedule.every(1).hour.do(write_to_excel)


You are currently writing the data at each interval to the same file, so you will overwrite the file every time. You could do a few things here:


Open the excel file (e.g. into a pandas DataFrame), append the new data and save it all back to disk. This is pretty inefficient though and will have problems once you have a lot of data.
Write the data to a database, extending it every hour. This is the most professional solution.
Write a new file to disk each hour, including e.g. the timestamp of the hour in the filename to make each file unique. This is simple and just means you iterate over the files one-by-one when reading them later to do analysis or plotting etc.


You could change your function to be like this, implementing the first option above:

def request_data_and_save(excel_file: str = "air_quality.xlsx"):
    request = requests.get("https://api.waqi.info/feed/paris/?token=?")
    request_text = request.text
    JSON = json.loads(request_text)

    filterJSON = {
        'time': str(JSON['data']['time']['s']),
        'co': str(JSON['data']['iaqi']['co']['v']),
        'h': str(JSON['data']['iaqi']['h']['v']),
        'no2': str(JSON['data']['iaqi']['no2']['v']),
        'o3': str(JSON['data']['iaqi']['o3']['v']),
        'p': str(JSON['data']['iaqi']['p']['v']),
        'pm10': str(JSON['data']['iaqi']['pm10']['v']),
        'pm25': str(JSON['data']['iaqi']['pm25']['v']),
        'so2': str(JSON['data']['iaqi']['so2']['v']),
        't': str(JSON['data']['iaqi']['t']['v']),
        'w': str(JSON['data']['iaqi']['w']['v']),
    }

    # Get a writer and append data to the file
    with pd.ExcelWriter(excel_file, mode="a") as xl:
        df = pd.DataFrame.from_dict(filterJSON)
        df.to_excel(xl)

if __name__ == "__main__":
    schedule.every().hour.do(write_to_excel)
    while True:
        schedule.run_pending()


NOTE: this code is not tested